Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
3
votes2
answers282
viewsA: Filter string REGEX C#
I made a Regexr with your pattern. The regular expression is: value=\"([\d,]+)\" In C# it looks a little different. var regex = new Regex(@"value=""([\d,]+)"""); Once done, just select group 1…
-
0
votes2
answers200
viewsA: Patch Methods with Route and Authorize - webApi
This is not the right way to test. HTML browsers do not support PUT nor DELETE. Use a more suitable tool for your tests, reimplently [HttpPut] and repeat the test. PATCH would be best suited to your…
-
6
votes1
answer181
viewsA: Python ORM similar to Django
Is there any database framework (ORM) similar to Django’s ORM? Yes, flame Sqlalchemy. He has a version for Flask. It is possible to use the Django framework, without relying specifically on the…
-
2
votes1
answer63
viewsA: View inside an area as default in MVC
The route is ok. The big problem here is in the View Engine, that is not something simple to solve. I will translate this response from the gringo OS: First you need to create a View Engine that…
-
1
votes1
answer81
viewsA: Lazyload even putting . include(t => t.Model)
The statement of Include must come before Where. The assembly of IQueryable can go wrong if you ride the Where and then use the Include: var clientes = db.Boletos .Include(i => i.Cliente) // Aqui…
-
2
votes3
answers1650
viewsA: Send All Checkbox via Post
This way is not good to use. FormCollection has several problems, and the correct is to go through the strong typing. Another thing is that you need to index each item on the list so that the Model…
-
0
votes1
answer96
viewsA: How to List Products from One MVC Distributor
I suppose your Model Produto be something like that: public class Produto { [Key] public int ProdutoId { get; set; } public int DistribuidoraId { get; set; } ... public virtual Distribuidora…
-
13
votes3
answers1592
viewsA: What is System.Linq for?
System.Linq is the namespace implementing the Language Integrated Query (LINQ), i.e., the syntax of C# to iterate selectively on collections. In the case, int[] by default does not have the method…
-
0
votes1
answer408
viewsA: Sqlconnection failure in C#
This is not a mistake. It’s a warning (Warning): Warning 1 The field 'Windowsformsapplication1.Form3.dataRead' is Never used C:... Windowsformsapplication1 Form3.Cs 23 23 Windowsformsapplication1…
-
4
votes1
answer177
viewsA: Automatic email sending from a website
Yes, using the Hangfire. Hangfire can schedule anything, not just emails. You can integrate Hangfire with Postal.Mvc, which produces emails as if they were Views. You can use Razor or ASPX.…
-
4
votes3
answers821
viewsA: What is the difference between "decimal. Divide" and the traditional "/" in C#?
/ is an operator. Decimal.Divide a method. An operator accepts overload; a method accepts polymorphism. The concepts are different; An operator has several types of return; a method has some…
-
4
votes3
answers1037
viewsA: Where dynamic Linq to SQL
As you want everything dynamic, there is the great package System.Linq.Dynamic who does it for you. Then with him it would be: listEmpresa = db.EMPRESA.Where(campo + "==@0", valor).ToList();…
-
2
votes1
answer258
viewsA: Id pass to new MVC 4 controller
As I said in the previous question, you need to fill in the EnrollmentId as Hidden if it has value, or bring the dropdown otherwise completed. A code suggestion would be as follows:…
-
1
votes1
answer1001
viewsA: How to register legal and physical persons in c# mvc?
The point is that you are using the same screen to register both a Praticante as to a Estabelecimento, which can make your logic very complicated. The best would be to have two screens: one for…
-
2
votes1
answer137
viewsA: User add date to List MVC 4
There are some ways to do it. The most didactic would be to create a Action in ComponentsController to create a discipline component using the Discipline id. For example: public ActionResult…
-
7
votes1
answer117
viewsA: Why do some libraries start with version "0.6" or "0.2" instead of using "1.2" or "1.6"?
Why do some libraries do this? Because their development teams don’t consider them stable. There are a number of reasons for this, such as maturity, usage time, adherence to a considerable amount of…
versioninganswered Leonel Sanches da Silva 88,623 -
4
votes2
answers801
viewsA: Keep table records synchronized between two different databases
So I’m thinking of creating a Trigger in the bank that does this job. It is the only viable alternative, especially considering that the technology in the old system is not as sophisticated as in…
-
7
votes2
answers2858
viewsA: Difference between Viewresult and Actionresult
ViewResult drift ActionResult. ActionResult is abstract, and serves as wildcard in return, which can be: ViewResult: Specifically returns a View; PartialViewResult: Specifically returns a Partial…
asp.net-mvc-5answered Leonel Sanches da Silva 88,623 -
2
votes1
answer65
viewsA: Entity Framework - Relationship Association Problem 1 to 0.. 1
Your modeling is wrong. A course unit must be registered elsewhere, for example in an entity UnidadeCurso: public class UnidadeCurso { [Key] public int UnidadeCursoId { get; set; } public int…
-
3
votes1
answer371
viewsA: Nullable<Datetime> 01/01/0001
Lacked a @ here: @if (item.DataPagamento.HasValue) { @item.DataPagamento.Value.ToShortDateString(); <span>teste</span> }
-
0
votes1
answer183
viewsA: LINQ to SQL with entities that already exist, inheritance and composition
Basically, inheritance mapping in LINQ to SQL can be done according to this tutorial. It is necessary to define a column as discriminator on the parent table. This parent table will have all parent…
-
1
votes1
answer61
viewsA: SQL data count filtered by multiple tables
Basically a great JOIN fix everything: select v.PrimeiroNome as "Nome do Vendedor", r.Nome as "Região" from Vendedores v inner join Cidades c on c.Id = v.IdCidade inner join Estados e on e.Id =…
-
9
votes3
answers1682
viewsA: Is it common to have multiple different servers for the same web application?
This is a commonly used approach? Not common. It’s a little extravagant, but it’s not wrong. Keeping each thing on a different server can bring me some kind of problem? The problems are more related…
-
1
votes2
answers281
viewsA: Count occurrences in tuples
You can use the excellent Counter of collections: from collections import Counter lista_contagens = Counter(map(lambda: x, x[0], lista)) # Isto imprime as contagens print(lista_contagens.values())…
pythonanswered Leonel Sanches da Silva 88,623 -
2
votes1
answer158
viewsA: Store List<Menu> In Memory or Cookie
There is also the Stack Overflow solution: Redis. O Redis can be installed on Windows. The Stack Overflow team wrote an excellent Redis integration module for their ASP.NET MVC application. JSON…
-
0
votes1
answer385
viewsA: Update , Insert into Entity Framework Using View?
I’m having an error in my project when trying to give an Update or an Insert via Entity Framework, where I’ve formatted a database view. According to the official SQL Server documentation (see…
-
6
votes1
answer1792
viewsA: Generate and download pdf file
This is the way much wrong to do. Nothing guarantees that you are actually manipulating the request with this. There are two ways you can resolve this correctly: Making GerarPDF return a byte[]; Do…
-
1
votes1
answer706
viewsA: How to pass data from a Dataset to an Excel spreadsheet C#?
Try using Epplus for this. Simpler. using (var excelPackage = new ExcelPackage()) { excelPackage.Workbook.Properties.Author = "Leandro Diaz"; excelPackage.Workbook.Properties.Title = "Minha…
-
0
votes1
answer215
viewsA: Job to write query data to an XML file
Well, it’s basically using the command xp_cmdshell: DECLARE @command VARCHAR(8000) = 'echo ' + @xml + ' > c:\meus\diretorios\teste.txt'; EXEC xp_cmdshell @command;…
sql-serveranswered Leonel Sanches da Silva 88,623 -
2
votes1
answer380
viewsA: Routine included in Threadpool to run in "background" does not let the application continue running
What am I doing wrong? Using a gigantic critical region. As possibly other requisitions make use of it, the requisitions (which, by the way, are threads also) are blocked until the process ends.…
-
6
votes1
answer1790
viewsA: Import Excel to Sql Server C#
Using the package Nuget Epplus: var arquivo = new FileInfo(Server.MapPath("importados/" + Label2.Text)); using (var package = new ExcelPackage(arquivo)) { // Obtendo o Workbook var workbook =…
-
2
votes1
answer87
viewsA: Data Annotation - error ratio 1:1
The 0.. 1 to 1 modeling in the Entity Framework is a little weird. The right one is like this: public class CieloRecorrencia { [Key] public int CieloRecorrenciaId { get; set; } // Este aqui não…
-
1
votes1
answer158
viewsA: LINQ TO XML Query with Optional Widget
A block try ... catch solve this well, no? try { var ConsutarPessoas = from p in xmldoc.Descendants("Pessoa") select new { CpfCnpj = p.Element("CpfCnpj").Value, Nome = p.Element("Nome").Value,…
-
2
votes1
answer662
viewsA: No Auto-Increment Primary Key for CPF in Entity Framework
The idea of using CPF as a primary key can be quite interesting within your system. Just decorate your key with [DatabaseGenerated(DatabaseGeneratedOption.None)] for the system to define the primary…
-
10
votes4
answers6487
viewsA: Maximum request size ASP.Net MVC
In the Web.Config, define the following: <configuration> ... <system.web> ... <httpRuntime maxRequestLength="1048576"/> ... </system.web> ... </system.webServer> ...…
-
6
votes1
answer154
viewsA: ASP.NET MVC Query Portal 4
As I recently used ASP.NET MVC 4 to build an application with RAZOR and found quite productive I ask you I can develop this new project using ASP.NET MVC 4? In short, yes. I can’t imagine what the…
asp.net-mvc-4answered Leonel Sanches da Silva 88,623 -
37
votes4
answers17728
viewsA: What is a scaffold?
What is? Scaffold is a pre-molded. The term comes borrowed from construction. The conversion technique of the Scaffold on an element of the ASP.NET MVC architecture is called Scaffolding. What is…
-
3
votes1
answer107
viewsA: Get Total Relationship Items 1:N
I’m guessing the following construction of your Models: public class Produto { [Key] public int ProdutoId { get; set; } [Required] public int Nome { get; set; } [Required] public decimal Preco {…
-
3
votes1
answer362
viewsA: Order of execution of Migrations
In the new versions of the Entity Framework there is some configuration that allows the execution of Migrations without a mandatory order? Yes, the automatic migration mechanism. In this case, the…
-
1
votes1
answer91
viewsA: Source code versioning with approval
The SVN already does that, but as the documentation itself says, it is really necessary this type of configuration? I say this because wrong changes can easily be reversed. The problem is easier to…
-
1
votes2
answers576
viewsA: Integration of two different applications in ASP.NET MVC
I just don’t know if this is the best way. I’ve thought about integrating this way using Dlls, I’ve thought about doing by Web API that on controller i made a call to the integration API by passing…
-
5
votes1
answer737
viewsA: How to create an application from scratch in ASP.NET MVC?
I have a better introduction for you. I’d like to understand where the whole code between the Controller and the Model until the seat is inserted. Well, you have just answered a part of your own…
-
1
votes1
answer1377
viewsA: Column for saving SQL Server change date and time
Yes. For insertions in your table declaration, use the following: CREATE TABLE TABELA ( ... DATA_CRIACAO DATETIME DEFAULT CURRENT_TIMESTAMP, ... ); For update will have to be by Trigger: ALTER…
-
0
votes2
answers62
viewsA: Pass text instead of id on dropdown
Using another construction of @Html.DropDownListFor: @Html.DropDownListFor(model => model.grupo.AnoCatequeseID, ((IEnumerable<AnoCatequese>)ViewBag.AnoCatequeseID).Select(ac => new…
-
1
votes2
answers973
viewsA: Inheritance X Composition - Mysql C# Entity
Its composition is incorrect. Cliente 0 to 1 or 1 to 1 ratio Pessoa. As I said in the previous answer, the right thing would be for you to do: [Table("cliente")] public class cliente { // Cliente…
-
5
votes1
answer176
viewsA: HTML5 rendering with Razor
According to W3schools itself: In HTML, the <input> has tag in end tag. In XHTML, the <input> tag must be properly closed, like this <input />. HTML5 follows the XHTML standard…
-
7
votes1
answer94
viewsA: Update to 2K records <Clients> how to do a single update instead of 2k separately
How to do a single update instead of 2k separately? Not using native Entity Framework. Simple as that. It doesn’t meet this kind of demand you have. Already the Entityframework.Extended meets,…
-
1
votes1
answer514
viewsA: ASP.NET MVC Post Date Format
I have the same problems in my systems. I implemented a DateTimeBinder that solves the problem: public class DateTimeModelBinder : DefaultModelBinder { public override object…
-
1
votes2
answers456
viewsA: col-Md-6 is not working on MVC
The classic ASP.NET MVC project sets up some improper things, like this one. Open the file Content/Site.css and comment or remove the following: /* Set width on the form input elements since they're…
-
7
votes2
answers2096
viewsA: Mysql and C#inheritance modeling
In this answer, I explain how to make inheritance for Legal and Physical Persons. Having this, Cliente and Fornecedor would be compositions of a Pessoa. See that in the answer quoted I talk about…