Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
3
votes1
answer1079
viewsA: ASP.NET MVC permissions system
I can do this with Claims, or I have my concept of what I can do with Claims wrong? In summary, yes. Let’s assume the following authorization attribute: [AttributeUsage(AttributeTargets.Method |…
-
2
votes2
answers1274
viewsA: Compare properties of an object with properties of a list
Yes. Once I answered in the SO gringo exactly about this. Below I will post an extension method to bring the different properties between two objects. Just you adapt to your logic: namespace…
-
7
votes1
answer4462
viewsA: Change port or something on IIS Express. Is there a way?
Right click on .csproj > Properties. Go on option Web and change the door in Project Url:…
-
2
votes2
answers125
viewsA: Find Values between two prefixes and swap one for the other
A simple way is by regular expression, using Regex: using System.Text.RegularExpressions; var padrao = @"13-00-00-00-(([0-9a-fA-F]{2}-){19})"; var re = new Regex(padrao, RegexOptions.IgnoreCase);…
c#answered Leonel Sanches da Silva 88,623 -
2
votes1
answer86
viewsA: How to give querySelector in attributes with space?
Something like that? document.querySelector("div[arvalue='Teste%20Novo']").style.backgroundColor = "green"; Or else: document.querySelector("div[arvalue='Teste\\ Novo']").style.backgroundColor =…
javascriptanswered Leonel Sanches da Silva 88,623 -
3
votes1
answer439
viewsA: Write Json Return to txt c#
If it’s a list of TabelaFipe, then you have to use an enumeration, not a simple object, in the type passage: var deserializedProduct =…
-
1
votes1
answer1073
viewsA: Export Datatables
Datatables has some function to export your data, which could be called through the buttons above the grid (in blue)? In short, yes, but you possibly will have to create your own buttons if the…
-
1
votes1
answer199
viewsA: Update table with data from another table decreasing character
I took a test here: declare @teste decimal(10, 3); select @teste = 3.456; select convert(decimal(10, 2), @teste); -- Resultado: 3.46 If the source and destination fields are decimal and different…
-
2
votes2
answers843
viewsA: Overwrite methods based on name only
In this case, we will have to be creative. Simply ignoring the arguments extrapolates the design of the C language#. First, the method, to be overwritten, needs to be virtual: public virtual int…
-
6
votes1
answer570
viewsA: What is the difference between Ajax.Beginform and Html.Beginform in Asp.net MVC
Basically, one builds a form using Ajax, and the other builds a simple form, both in HTML. In Ajax forms, the request is sent by Javascript and there is usually no transition from the current page:…
-
2
votes1
answer231
viewsA: Error installing Python Polyglot package by Pip
Pip has a Unicode bug that hasn’t been fixed yet. You’ll need to download the source and install the .egg, thus: PS C:\Users\cigano\Documents\python-projects> git clone…
pythonanswered Leonel Sanches da Silva 88,623 -
0
votes1
answer116
viewsA: How to use the Npgsql reference for framework versions smaller than 4.5?
Support for . NET 4.0 was dropped last year (from the date of this response, in 2015), in version 3.0. Therefore, the latest version that can be used is the 2.2.7. If using Nuget, don’t forget to…
-
0
votes2
answers507
viewsA: Increment in Python list
There are several problems with this code. I consider that maybe you are imagining a way Python works that does not exist. The solution involves iterating your IP list as follows: lista =…
pythonanswered Leonel Sanches da Silva 88,623 -
5
votes1
answer3721
viewsA: Insert X amount of characters in SQL Server field
If you want to enter the zeros in the selection, you can do so: SELECT A.*, REPLICATE('0', 8 - LEN(B.CODIGO)) + B.CODIGO FROM TABELA_A A INNER JOIN TABELA_B B ON (...) The idea is that it doesn’t…
-
3
votes1
answer130
viewsA: Problem with Bundle on the server
You need to install the Static Content IIS so that CSS files are distributed with the correct MIME type. This configuration can be done through the menu Enable or Disable Windows Features (Add or…
-
0
votes1
answer230
viewsA: More efficient code for making an iTextSharp template in ASP.NET MVC?
The most efficient code includes using a library of my own. Works with all versions of iTextSharp, including version 4, which is built into the project. The general idea is to transform a View Razor…
-
4
votes1
answer171
viewsA: Delete Devexpress controls
Right click on .csproj, option Unload Project. Again right click on the file .csproj, option "Edit Your project.csproj". Look for licenses.licx. Delete all tags that have to do with this name. Save,…
-
2
votes1
answer493
viewsA: Entity Framework: Error creating the database
The problem is here: EXECUTE sp_rename @objname = N'dbo.RiscoCardiaco.Cliente_Id', @newname = N'Cliente_ClienteId', @objtype = N'COLUMN' ... EXECUTE sp_rename @objname = N'dbo.Endereco.Cliente_Id',…
-
5
votes2
answers499
viewsA: How to add one more condition in a query using Linux?
For this case, do not use Join. Use in the Where. Linq is not SQL: var consultaVeiculo = (from e in dm.Tabela_SegVeiculos join r in dm.Tabela_VeiculoRefers on e.Modelo equals r.Cod_referencia into…
-
2
votes3
answers394
viewsA: Is it possible to add string Connection within a class?
When you use: ConfigurationManager.ConnectionStrings["Conexao"].ConnectionString Is using the active project configuration, ie the file .config connected to the application that is running. Thus,…
-
0
votes1
answer152
viewsA: Button with link on MVC5 is not working
No need to use @Url.RouteUrl for your case. Use instead @Url.Action: <a href="@Url.Action("TornarPagina", "Home", new { alt = "Clique Aqui!" })"> ... Do not use "Controller" in the name of…
-
2
votes1
answer331
viewsA: Right Way to Make Relationship One To Many Using C# and Mongodb
That’s the right way to make this relationship? Yes, whereas Comentario is mainly related to a Sistema. Comentario will be defined as a Sistema. What may have been missing, if you like, is a DBRef…
-
2
votes1
answer158
viewsA: .Orderby dynamically in Lambda
That one Include should therefore be in line with the principle of early loading: IQueryable<produto> produtos = db.produtos .Include(i => i.Cidade) .Include(i =>…
-
2
votes2
answers945
viewsA: Compare values with different conditionals in the same table
(datarecebimento <= dataprevista OR datarecebimento <= dataAgendamento) It is not the logical negation of (datarecebimento > dataprevista OR datarecebimento > dataAgendamento) By your…
-
2
votes1
answer141
viewsA: What to test/implement in a viewmodel?
Since Viewmodel, by my understanding, is responsible for "passing" the data from the View layer to the Model, outside the responsibility of doing this intermediation, what I implement most in it?…
-
6
votes2
answers458
viewsA: How to convert Camelcase to snake_case in C#?
It would be something like that: string stringSnake = string.Concat( stringCamel.Select((x, i) => i > 0 && char.IsUpper(x) ? "_" + x.ToString().ToLower() : x.ToString().ToLower()) ); I…
-
7
votes3
answers4632
viewsA: What is the difference between one-dimensional and two-dimensional matrix?
One-dimensional matrix has only one dimension. It is also called a vector. In pseudolanguage: var vetor = inteiro[10]; In Java: int[] vetor = new int[10]; In C++: int vetor[10]; Two-dimensional…
-
6
votes3
answers2619
viewsA: Can subqueries decrease performance? Myth or truth?
Subqueries can decrease performance? In short, they can. But it’s not always like this. Subqueries at all times cause performance problems, or this problem may occur depending on a specific context?…
-
4
votes1
answer829
viewsA: Url friendly in ASP.NET Web Forms
In fact, it’s not Global.asax just that you do it. You need to install this package first. Installed this, you need to put the line below in your Application_Start:…
-
1
votes1
answer1762
viewsA: What steps to implement SSL/TSL in an ASP.NET MVC application
I need to implement something in the software layer or is it just infra? Actually everything is ready. You just need to enable your application. Click on the project file of your ASP.NET MVC…
-
3
votes1
answer238
viewsA: How to do Scaffolding in ASP.Net MVC with text and resources in en-BR?
I’m gonna need this answer to continue the hook. Considering you did everything that was in the link response, let’s set up a Model: public class CustomUser { [Key] public Guid CustomUserId { get;…
-
2
votes2
answers48
viewsA: Check in a table if a user is not registered
It would be something like: SELECT distinct * FROM usuarios USU INNER JOIN sala_usuarios SALA ON USU.id_usuario = SALA.codigo_usuario_fk INNER JOIN predio PRE ON PRE.codigo_predio =…
-
2
votes3
answers271
viewsA: Change read-only property in class itself
Then the way is not to use auto properties: public class MinhaClasse { private string _propriedadeDeMinhaClasse; public string PropriedadeDeMinhaClasse { get { return _propriedadeDeMinhaClasse; } }…
-
31
votes1
answer50008
viewsA: Masks with jQuery: Phone, CPF and CNPJ
Well, I will make a super quick introduction to jQuery, enough for you to read other materials and understand. Introduction to jQuery (in 2 and a half minutes, I think) jQuery is a tool that locates…
-
10
votes2
answers7839
viewsA: What is the difference between View and Materialized View?
Basically, the View materialized is a separate data object, while the View is a projection on top of other data objects, calculated from the moment some selection operation is done on it. In terms…
-
1
votes1
answer115
viewsA: Actionresult and async method Using Fastmapper, Typeadpter Error
For the home page documentation, Adapt is not asynchronous. Switch to: // GET: Credito/Details/5 public async Task<ActionResult> Details(int? id) { if (id == null) { return new…
-
3
votes1
answer118
viewsA: How to create a method that takes only one string and returns a generic type? . NET MVC
This approach is not good. You are preferring to solve a string for a type in an authorization attribute. The correct one would be to specify a type in the authorization attribute. Something like:…
-
1
votes1
answer2055
viewsA: Hide URL parameter in MVC 5
I will discuss in response some ways and recommend a. 1. Using slugs (recommended) I speak of it in these answers: Mount URL without the Action or Controller name or both Hide Actionlink parameter…
asp.net-mvc-5answered Leonel Sanches da Silva 88,623 -
3
votes1
answer3043
viewsA: How to use Microsoft ASP.Net MVC in English?
Just install the package and set your globalization configuration as follows (Web.config): <configuration> <system.web> ... <globalization culture="pt-BR" uiCulture="pt-BR"…
-
6
votes3
answers1063
viewsA: What is the difference between System.Web.Http and System.Web.Mvc?
What’s the difference between System.Web.Http and System.Web.Mvc? Here we are talking about namespaces, and serving different purposes. The implementation of System.Web.Mvc is here. The…
-
1
votes1
answer242
viewsA: Error using EF6 Codefirst with Mysql
I found several problems in your configuration. Change your Connection string for: <connectionStrings> <add name="NortaoCultContext" providerName="MySql.Data.MySqlClient"…
-
5
votes1
answer98
viewsA: Returning the values of a model dynamically in . NET MVC
Interfaces can be a good starting point. Implement an interface for the three types: public class User : IMinhaInterface { ... } public class Admin : IMinhaInterface { ... } public class Client :…
-
2
votes1
answer33
viewsA: Unidentified tenum in html
In fact your Helper was not recognized by View. There are two ways to solve: 1. Making @using in the statement of View of namespace where the Helper was implemented @model SeuProjeto.Models.SeuModel…
-
3
votes3
answers763
viewsA: I need to validate a TXT layout in C#
The way is to use the Nuget Filehelpers package. It is a tool that handles these types of files, although the lines are different. How the lines are different according to the 2nd column, is a case…
-
4
votes1
answer263
viewsA: Passing model via dynamic form parameter in . NET MVC
You can. Use generic: public class Handle { public string Make<T>(T model, string handle) where T: class { db.Set<T>.Where(...) ... return handle; } } EDIT To parameterize the Where,…
-
8
votes2
answers955
viewsA: How to manage approval and production environments with Team Services?
The best introduction is this one. In projects that use Git, a good practice that is becoming common is not performing commits and pushes in the branch master: this branch is usually used for…
-
2
votes1
answer390
viewsA: Enter additional data, from the bank, into the user’s Claims. What is the best time or the right way to do it?
In the creation or editing of the user. Claims are portions of information that uniquely identify a user. A great example is in this answer, which I will format for your case. Notice that…
-
12
votes1
answer3777
viewsA: When should I use Modelstate.Isvalid?
The verification of the validity of ModelState should be done every time a form is sent. Not only for inserts, edits and exclusions. The ModelState not only serves to Models, but also for…
-
5
votes1
answer588
viewsA: My software is being blocked by Windows Smartscreen
The Windows Smartscreen is the protection feature of Microsoft Windows for applications that have not been certified by Microsoft. The idea is usually to detect malicious applications that may…
-
2
votes1
answer487
viewsA: How to create master-detail form using a Viewmodel
In fact you can pass the data to the View yes. The problem is another: you are trying to put together a master-detail form and possibly not getting the way you need to get. The principle of assembly…