Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
6
votes5
answers4008
viewsA: Regex take from one point to the other within a text
I put together another regular expression for you that looked like this: From:\s*([\.\w\d\s]*)\nMessage:\s*([\.\w\d\s]*)\n I made a proof of concept here.…
-
1
votes1
answer141
viewsA: Branchs and merge structure . NET MVC
The correct thing would be to publish only from master, not from a development branch. Also, each bug fix or development should have its branch separate, and not use a single branch for all…
-
3
votes1
answer364
viewsA: An Object with the same key already exists in the Objectstatemanager. The Objectstatemanager cannot track Multiple Objects with the same key
This is because you are selecting the user several times. By default, the Entity Framework monitors all loaded objects, even if there is no change in them. To prevent read-only objects from being…
-
3
votes1
answer734
viewsA: Regex take more than one occurrence in a string
(\d{2})* for zero or more occurrences. (\d{2})+ for one or more occurrences. See a test here. To iterate over all occurrences, use: foreach (Match m in Regex.Matches("12 hoje vai 45 na serra pelada…
-
1
votes1
answer307
viewsA: How to fill a code column for reference with repeated values
You do not need to number the rows by SQL. You can do this by yourself Controller, converting each dependent object into an anonymous object: public ActionResult Dependente() { var i = 1; var…
-
3
votes1
answer1511
viewsA: Composite primary key with entities in the Entity Framework
It would be a classical associative entity, not necessarily a composite key case. Do it as follows: public class ProjetoDocumento { [Key] public int ProjetoDocumentoId { get; set; } public int…
-
2
votes2
answers80
viewsA: How to ensure that the instantiation of a class is done only through "using"?
Just inside a using, nay. The idea is that the Garbage Collector’s . NET is able to detect when an object will no longer be used within the context of the application, expiring and eliminating the…
-
2
votes1
answer111
viewsA: How to always keep 1 record in BD after inserting with entityframework?
We need to contextualize the question so that this answer makes sense. Yes. You should always search using FirstOrDefault(). If there are no records, the returned object will be null: public…
-
4
votes2
answers707
viewsA: Mysql to Python 3 connector
Apparently this is a classic problem of this plugin in particular. Using the pip, perform the following: pip install --allow-all-external mysql-connector-python Adjust your file settings.py to the…
-
1
votes1
answer289
viewsA: How to map a table without PK with entityframework?
This is not how you map a table that will only have one record. Do it this way: public class Configuracoes { [Key] public Guid ConfiguracoesId { get; set; } public int MaximoFilas { get; set; }…
-
2
votes4
answers7856
viewsA: Calculate Total Hours by identifying Equal Time Intervals
For this answer, I am using this Sqlfiddle, provided by the author of the question. The sentence went like this: SELECT MATRICULA_COLABORADOR, DATA_AUTORIZACAO, DATA_INICIO_HE, CONVERT(VARCHAR(10),…
-
24
votes3
answers25089
viewsA: What is the function of a static method?
What is the function of a static method? Execute a method without needing to instantiate a class. A class, roughly speaking, is a set of variables, properties, and methods. When the first two are…
-
2
votes1
answer114
viewsA: Method finishes its execution unexpectedly when calling another method
This doesn’t return one IEnumerable<ModelEntities>: var query = //query Linq select new ModelEntities { //inicializando campos }; return query; This returns a IQueryable. The return nor even…
-
1
votes1
answer630
viewsA: Inner Join, multiple Inserts with multiple conditions
It seems to me to be a database exercise, not least because the statement does not make much sense. I’m guessing all primary keys are IDENTITY. The basic insertion syntax is: INSERT INTO tblTickets…
-
2
votes1
answer1761
viewsA: Error: There are no Primary or candidate Keys in the referenced table
This list of table columns parceria_conta_corrente_ao dt_conta_corrente, id_periodo, id_ao, id_gr_cliente, id_cliente, data_importacao_cli_gr_cli, hp2 It is not a primary key to…
-
4
votes2
answers475
viewsA: Is it feasible to use more than one Dbcontext for in the same database?
In this scenario, it is feasible to use more than one context? Yes, it is both feasible and recommended for some cases, where it is not interesting the visibility of all entities in a given context.…
-
1
votes1
answer204
viewsA: Migration of iis from visual studio to iis7 location does not access the database
Open IIS Manager (Internet Information Services Provider); Expand the node Websites from your server. Find the published website and click on it; Click on Error Pages (Error Pages. NET); On the…
-
1
votes1
answer69
viewsA: Restart count when changing year
Quite simple. Just change your GroupBy(). By comment he was asked about the totalization of all records. This can be done by initializing a variable outside the loop and incrementing it within the…
-
4
votes1
answer891
viewsA: Trigger that calculates and updates age
It won’t. Missed the use of the special table INSERTED, which precisely indicates the set of altered records of the table in question. What you really want is a Stored Procedure. Trigger is only…
-
4
votes1
answer495
viewsA: What are the positives of using Aspx View Engine instead of Razor?
What drives someone to use this View Engine with ASP.Net MVC? Basically, the legacy. Imagine that you want to port a large system made in Web Forms (ASPX) to MVC. Saving the visual layer of large…
-
5
votes1
answer387
viewsA: What are Global.asax methods, when are they fired and good practices?
The Global.asax archive derives System.Web.HttpApplication. Her source is here. The methods of HttpApplication are here. I do not know if it is worth explaining one by one in this reply already…
-
0
votes1
answer973
viewsA: Perform field sum in the table
In your place, I would group the records by NmPessoa or some identifier field of the person: @foreach (var item in Model.GroupBy(g => g.NmPessoa)) { var subtotal = 0; foreach (var contribuicoes…
-
1
votes1
answer166
viewsA: Database replication in WPF + EF system
I think for your case a second level cache should solve. Entity Framework has a package that implements this. You can download it here. According to the developer’s blog, the setup is quite simple.…
-
2
votes1
answer304
viewsA: Table for storing expenses and revenues. Cyclical information
I have a monthly expense for 36 months or I have an indefinite quarterly income. What would be the best way to store this information, thinking about minimizing the size of the bank and making it…
-
3
votes2
answers2743
viewsA: How do I set a private property in Python? And is there a protected property?
As @Joãopedroalves replies, there is no private property. For protected properties, it would be a schema using modifiers @property and @nomedaproperty.setter: class StackExchange(object): def…
-
4
votes2
answers816
viewsA: Convert hexadecimal to integer
In fact the conversion from hexadecimal to integer requires the use of Parse, more specifically this format: var codLiberacao = int.Parse(hex, System.Globalization.NumberStyles.HexNumber); Only I…
-
1
votes2
answers3494
viewsA: ASP NET MVC Include Url Parameter on all pages
I think something like this could solve your problem: routes.MapRoute("Default", "Cliente/{id}", new {controller = "Cliente", action = "Pesquisar", id = UrlParameter.Optional}); Your controller…
-
0
votes1
answer434
viewsA: Returning selected data to Razor in anonymous object
Two forms: The recommended form Create a ViewModel typed with the 3 fields you need. Pass to Razor a typed collection: @model IEnumerable<PortalRH.DomainModel.ViewModels.UsuarioViewModel> The…
-
1
votes1
answer108
viewsA: Sort result with 4 different columns
I don’t know what that data looks like, but I’m gonna assume that’s all VARCHAR for this answer. Depending on the comments I change. I think the best approach would be with a SELECT inside another,…
-
1
votes2
answers437
viewsA: Sorting in recursive query
First of all, you need to have a grouping criterion. I’m going to invent one. For example, GrupoId. Having this, just select by GrupoId and sort at the end of the query as below: USE TESTE GO WITH…
-
1
votes1
answer50
viewsA: Global filters in Entity Framework
You can create an extension method, for example: public static class EntityFrameworkExtensions { public static IEnumerable<T> Ativos<T>(this IDbSet<T> dados) { return dados.Where(x…
entity-framework-6answered Leonel Sanches da Silva 88,623 -
2
votes2
answers1232
viewsA: Import Itaucripto DLL into VB
First manage an Interop Assembly. This DLL is a COM Assembly, not directly compatible with the .NET. Then include this Assembly in your code to access the COM interfaces. Done that, you need to…
-
9
votes7
answers1682
viewsA: Make the class builder private?
The technical explanation is simple: the constructor cannot be accessed from outside the class. Hence the error. Private constructors are important when you want to force parameters for the exposed…
-
12
votes2
answers9060
viewsA: Best practice for logging the system
Since what you want to register involves interception of actions, the correct thing is to combine some log solution ( @Maniero response) with proxy dynamic, this interception being made by the…
-
16
votes2
answers1634
viewsA: What is ASP.NET vNext? What is the correct name?
What is ASP.Net vNext? A part of you replied. It would be the initial working name of the new architectural model of ASP.NET, but it was a nickname that lasted a short time. Scott Hanselman, one of…
asp.net-mvc asp.net asp.net-web-api asp.net-core nomenclatureanswered Leonel Sanches da Silva 88,623 -
6
votes3
answers7424
viewsA: What are the main differences between VB.NET and C#?
In addition to syntax, what are the main differences between these two languages? There is an article in Codeproject that illustrates the differences extensively. It is not worth commenting on all…
-
2
votes1
answer5879
viewsA: Recursive query
Well, it seems to me only a matter of adjustment. Just concatenate the previous level name with the current recursion level: USE TESTE GO WITH Niveis AS ( -- Membro âncora SELECT Id, IdPai,…
-
12
votes2
answers19790
viewsA: Delete all tables from a database at once
For all tables, run: EXEC sp_MSForEachTable 'TRUNCATE TABLE ?' Holds for SQL Server 2005 and higher. May fail with enabled constraints. To delete everything with constraints, use: -- desabilitar…
-
11
votes2
answers511
viewsA: What are nesting guys for?
Basically, scope limitation, but I’ll make a small change so that the utility is better understood: public class A { // Propriedades e métodos da classe A class B { // Propriedades e métodos da…
-
3
votes2
answers6021
viewsA: Button/link inside a view redirecting to another view
You don’t have to use @Url.Action: <a href="/Ativos/Index/@Model.Id" title="Cancelar" class="btn btn-info"> <span class="glyphicon glyphicon-edit" aria-hidden="true"></span> Ativos…
-
1
votes5
answers6761
viewsA: How to create composite key with Entity Framework 6
For Attributes there could be no inheritance. I would stay so: public class Subgrupo { [Key] public int Id {get;set;} [ForeignKey("Cliente"), Column(Order = 0)] public int GrupoId {get;set;}…
-
4
votes1
answer66
viewsA: What are and how the following statements work in Web Forms pages: <% %>, <%# %> and <%: %>
<% %> This statement accepts executable code, but returns nothing to the web page. It depends. Actually that’s not quite what you put. This is the markup inherited from ASP Classic. It simply…
-
5
votes1
answer65
viewsA: What is System.Void type
System.Void only useful using Reflection, if there is programmer desire to know when a method has as return void. The structure exists basically to resolve issues between compiler and CLR, in which…
-
2
votes2
answers1155
viewsA: Two actions in the same View
Assuming that Modal is already properly hidden, the following statement should resolve: <div class="modal-body"> @Html.Partial("~/Views/Divergente/Relatar.cshtml", new Divergente())…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
1
votes1
answer548
viewsA: Subdomain does not load styles and scripts
This is the subdomain source code on the date of this reply. Note that you have loaded scripts and css correctly into <head> in minified form: <!DOCTYPE html> <html> <head>…
asp.net-mvc route laravel-routes subdomain asp.net-mvc-routinganswered Leonel Sanches da Silva 88,623 -
3
votes3
answers190
viewsA: Several tables that should represent a single entity
Yes. Her name is Helper, which is a variation of Utility. Since the methods are very similar, you can centralize the common business logic within the Helper and call only one method that does…
-
2
votes1
answer735
viewsA: Regularexpression only letters in the Model
The right thing would be: [RegularExpression(@"^[a-zA-Z]+$", ErrorMessage = "Use apenas caracteres alfabéticos.")] public String MinhaString { get; set; }
-
7
votes3
answers1799
viewsA: What a difference between Dropdownlistfor and Dropdownlist
Complementing the @Laerte response: The DropDownList can be used for elements outside the Model, as for example in case the programmer does not want to implement a ViewModel for needing only one…
-
4
votes1
answer7480
viewsQ: ORA-00980: synonym Translation is no longer Valid
What this mistake means? What actions can be taken to remedy it?
oracleasked Leonel Sanches da Silva 88,623 -
0
votes2
answers1763
viewsA: Error updating Entity entries
The error is quite clear: System.Data.SqlClient.SqlException HResult=-2146232060 Message=Violation of PRIMARY KEY constraint 'ARQUIVO_VERSAO_PK'. Cannot insert duplicate key in object…