Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
8
votes2
answers611
viewsA: Suggestion Migration System and modeling of individuals and legal entities in system with Entity Framework
First let’s analyze whether the derivation of Pessoa is a composition or an inheritance. As a Pessoa cannot be both physical and legal at the same time, so it is a case of inheritance (a table…
-
2
votes1
answer785
viewsA: Error "must be str, not list" while writing to file
There are a lot of things wrong here. Starting with: arqParcial=open("parcial.txt","r") You are opening the file in read-only mode. That is, you will not write further in your code, which seems to…
pythonanswered Leonel Sanches da Silva 88,623 -
0
votes2
answers130
viewsA: Removing part of the link on ASP.NET MVC routes
Above the route Default, use like this: routes.MapRoute( name: "Relatorios", url: "{empresa}/Relatorios/{action}", defaults: new { empresa = "", controller = "Relatorios", action = "Index" } );…
-
2
votes2
answers1031
viewsA: How to call an Html.Action("my page") via jquery?
I don’t really understand what your code does, but in my systems I usually graft modal into HTML like this: <script type="text/javascript"> $("#meu-botao").click(function () {…
-
5
votes2
answers954
viewsA: Exhaust character
Suppose you are making a small program to test these escape characters, and want to print on the screen. Good examples to get started are \" and \'. I did the following Fiddle: using System; public…
c#answered Leonel Sanches da Silva 88,623 -
2
votes3
answers1667
viewsA: Function to format dates
In Moment js., would look like this: var data_formatada = moment(dt, "DD-MM-YYYY").format("DD/MM/YYYY");
-
2
votes2
answers1539
viewsA: Pass Select html value to Controller via Post
If you want to pass CidadeId to the Controller, use the appropriate variable name already does it for you: <select id="CidadeId" class="form-control"> <option>Carregar…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
4
votes2
answers244
viewsA: What is the best way to publish my C# Asp.NET application on Azure?
How best to publish my C# Asp.NET application to Azure? Using Web Deploy. It is a built-in method within the Visual Studio interface. Simply download the Azure publication profile and import into…
-
3
votes1
answer67
viewsA: Jquery does not send the parameter to search
If it is GET, you need to put the parameter in the URL, otherwise it will not work, obviously: $("#NumeroContrato").autocomplete({ source: function (request, response) { $.ajax({ type: 'GET', url:…
-
2
votes2
answers534
viewsA: LINQ update of all listed items (changing the status of all listed items)
First of all, do not use these two commands: context.Connection.Open(); context.Connection.Close(); Entity Framework closes the connection when necessary. You don’t have to do this manually. This…
-
2
votes1
answer437
viewsA: @Html.Editorfor Datetime property remove hh:mm:ss
Visualization Create in Views\Shared the directory DisplayTemplates. Within it, create a View empty call DateTime.cs. Within this View, put the following: @model DateTime? @if (Model.HasValue) {…
-
1
votes1
answer128
viewsA: Perform a select and return the emails in a list
Well, if you set up this list without problems: List<ModeloAniversariante> lst = new List<ModeloAniversariante>(); And you were able to correctly insert the result of your selection:…
-
2
votes1
answer1173
viewsA: Asp.net MVC Models Heritage
The modeling is correct, but I don’t understand why Viewmodels are treated as Models in your system. If database generation was done correctly, there will be a table Pessoas with all fields combined…
-
1
votes1
answer887
viewsA: How to generate a hash for the user password with ASP.NET MVC and . NET 4.5
There are several. A Nuget search on Bcrypt brings a variety of them. The ASP.NET Identity password algorithm is here. You can still use the algorithm of your preference. Here’s an example with…
-
2
votes2
answers375
viewsA: Should I compress files to save to the database?
Since many systems save the files (images, pdf’s, doc’s, etc.) in the database, I would like to know if it is a good practice to compress these files by zipping them, for example. Yes, and quite…
-
2
votes1
answer79
viewsA: List most frequent items in the database using LINQ
It’s not much of a secret: var grupos = db.Entidade .GroupBy(e => e.Nome) .OrderByDescending(g => g.Count()) .ToList(); Each element of grupos is a special enumeration (called Grouping) which…
-
3
votes2
answers2752
viewsA: Datatable Jquery Paging
There is the possibility to set the number of pages without having the records? Not. I want more efficient paging, load page data when clicked on page. It’s what it already does. You just need to…
answered Leonel Sanches da Silva 88,623 -
2
votes1
answer187
viewsA: Pass the Dropdownlistfor value through a @Url.Action
By Javascript. Change your link to have the following: <a id="MeuLink" style="text-decoration: none;" title="Incluir Paciente"><span class="fui-plus-circle" style="font-size:…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
3
votes1
answer491
viewsA: What are the free libraries options for ASP.NET MVC PDF generation?
Razorpdf2 (my own); Mvcrazortopdf; Pdfsharp; Rotating; Ironpdf (paid); Spire.PDF; Remembering that the first two are just envelopes of the iTextSharp, which has an Affero license (free to develop,…
-
0
votes1
answer717
viewsA: C# Entity Framework Invalid Object name 'sys.default_constraints'
There is nothing wrong with the Entity Framework. Only your login does not have permissions. Check with the team responsible for the database if there are any DENY for metadatabases or if login has…
-
2
votes1
answer77
viewsA: Entity Framework - Data Access Tips
Have any hints to do this or I have to use Lazy loading same? Do not materialize the column when selecting. Do as follows: var arquivos = db.Arquivos .Where(...) .Select(a => new { a.ArquivoID,…
-
4
votes1
answer91
viewsA: Entityframework Executesqlcommand not accepting parameter
If the idea is to use as ADO.NET, you can get the DbConnection of context and execute the command using SqlParameters normally: using (var connection = dbMailEnable.Database.Connection as…
-
2
votes1
answer203
viewsA: Differentiate list of items shown in the View using "Individual User Account" Asp.Net MVC 5
Projects with "Individual User Accounts" come with ASP.NET Identity installed by default. To do what you want, your entities should be modeled containing the following: public class Filme { [Key]…
-
3
votes1
answer683
viewsA: C# Return Value of a Thread
I created a database connection class that I intend to use Thread to make queries faster. This does not make the consultations faster. It only allows you to perform queries in parallel, and the mode…
-
1
votes1
answer515
viewsA: Middleware with ASP.NET MVC and . NET 4.5
In ASP.NET MVC there is no such concept of "middleware". What exists are user architectures and authentication that can be embedded into the application, which is an approach that I believe is close…
-
8
votes1
answer3602
viewsA: Linq Compare two lists of different types
Thus: var aContemB = !b.Except(a.Select(p => p.Tag).ToList()).Any(); That is, it checks if any item of B is an exception to A, and checks whether the result has elements. If there is an error,…
-
1
votes1
answer206
viewsA: Argument data type xml is invalid for argument 1 of Len Function
In SQL Server, len() does not work with XML type. You’ll need to use datalength() in place. In the Entity Framework, datalength() wears like this: _context.PreListaPostagemLog .Where(p => p.IdPlp…
-
0
votes1
answer32
viewsA: Pagination with EF 7 Asp.net 5 MSQL 2008
Yes, the Pagedlist.Mvc. I also recommend installing the Pagedlist.Entityframework to support asynchronous operations.…
-
11
votes3
answers10118
viewsA: Where should the business rule be in the MVC standard?
This is the standard or recommended to be? The recommended is always the simplest or quickest. If separation is necessary for some reason, go the way of separation. Personally speaking, I rarely do…
-
3
votes2
answers190
viewsA: RU with TPT inheritance and audit fields
Your project draws my attention by not following several standards recommended for the Entity Framework, starting with the non-use of Migrations, that saves you from generating scripts to update…
-
12
votes1
answer498
viewsA: When does the Entity Framework execute the query of a Iqueryable?
In short, at the moment it is IQueryable is converted to IEnumerable. Detailing a little more, the following methods trigger this conversion: ToList(); AsEnumerable(); Count(); Any(); First();…
-
6
votes1
answer493
viewsA: How to mount SELECT in lambda C#?
Would look like this: var produtos = db.Historicos .Include(h => h.Produto) .OrderByDescending(h => h.HistoricoData) .GroupBy(h => h.ProdutoId) .Select(group => group.FirstOrDefault())…
-
4
votes2
answers1283
viewsA: SELECT 3 different tables using DAPPER?
First, it is important to say that Dapper works very well as an addition to the Entity Framework. Using only Dapper in your application can result in a loss of productivity, since Dapper does not…
-
5
votes2
answers236
viewsA: Do Regex.Split on what is not between "..."
The big problem with this is that the regular expression parser doesn’t know what a quote opens and a quote closes. For example: "line2", "hello,world" "line2" would be a group, ", " would be…
-
2
votes1
answer93
viewsA: Dbentityentry.State vs Dbpropertyentry.Ismodified
When I apply the changes through the DbContext.SaveChangesAsync() all model properties will be updated in the database or only those that have actually been modified? All properties are updated,…
-
2
votes2
answers266
viewsA: Create tooltips using Attributes
I would say that the ideal is for you to write your own extension to generate the <input>. The original source can help. See this method: private static MvcHtmlString InputHelper(HtmlHelper…
-
4
votes1
answer1002
viewsA: Update Many to Many Entity Framework c#
This error is quite common, especially because you are learning Entity Framework now. In doing this: var artistaAtual = Db.Artistas .FirstOrDefault(a => a.ArtistaId == artista.ArtistaId); You’re…
-
2
votes1
answer30
viewsA: Using KEY element
How could you take away Key’s need or even generate a pseudo ID ? The most interesting way to do this is to unify all the structures into one Viewmodel with one more property. Let’s call linha. In…
-
4
votes2
answers222
viewsA: Update model partially with Webapi2
This approach is right? Yes, second support of RFC 5789, which explains how and when to use the PATCH. I must do only one method? If the partial update requires only one method, yes. If you need…
-
1
votes1
answer603
viewsA: Message de Aguarde when clicking the save button
I usually do like this: $('form').on('submit', function () { $('button[type="submit"]').prop('disabled', true).text("Aguarde..."); setTimeout(function () {…
-
2
votes1
answer249
viewsA: Complex Entity Framework Update
If the modeling is 0 or 1 address for an artist, then your modeling is incorrect. Do it this way: // Repare que retirei os construtores das propriedades de navegação. // Isto porque eles não são…
-
2
votes3
answers830
viewsA: Convert rows to columns (Pivot?)
I adapted this answer for your need. Use not only PIVOT, but also dynamic query construction because the number of columns will be undefined: DECLARE @MaxCount INT, @coluna_ddd CHAR(3) = 'ddd', @ddd…
-
1
votes2
answers424
viewsA: Mutiplos projects in MVC and Webapi
I was able to inject Class Libraries into MVC using Unity.Mvc. However, some warnings need to be given: Unity conflicts with ASP.NET Identity. I could never solve the configuration to work; As Views…
-
2
votes2
answers503
viewsA: Good practices when working with file processing
With my little experience, I know that the large volume of information makes the processing take a long time, reaching more than an hour and end up causing timeout. I believe that just increasing…
-
1
votes2
answers112
viewsA: SESSION: System confuses users who access it simultaneously
This is the wrong way to persist session user data in ASP.NET MVC. The alternatives to this are: Using an object derived from ProfileBase (explain here); Using an authentication provider such as…
-
3
votes2
answers355
viewsA: Lambda, Where com subconsulta
It is quite wrong your query. From what I understand of her, do the following: var EP = db.EtapaProcess .Include(t => t.Cliente) .Where(x => x.EP == ep) // ep é uma variável que viria de algum…
-
1
votes1
answer1002
viewsA: Connect to SQL Server on remote server
One thing that happens on some servers I’ve already touched is that you don’t need to specify the instance in case of remote connection. Just try using: Data…
-
7
votes4
answers1308
viewsA: What is the purpose of an empty parenthesis "()" in a regular expression?
A priori, no. Parentheses are usually used to identify groups. Groups, in turn, are used for operations such as extracting specific information or locating areas to replace the considered character…
regexanswered Leonel Sanches da Silva 88,623 -
4
votes1
answer310
viewsA: Many Update to Many Entity Framework c#
This is the hard way to do it. This Fluent API configuration has long since been exceeded. Set your associative entity manually: public class ArtistaCategoria { [Key] public int ArtistaCategoriaId {…
-
6
votes3
answers157
viewsA: How does field initialization work in constructors?
Because your class also wins an implicit constructor, nicknamed ctor. It is created when there are no constructors defined by the programmer. I don’t know if you ever had this idea of putting a…