Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
1
votes1
answer185
viewsA: Use Jquery Autocomplete in Id properties
Autocomplete is correct. The behavior would be right if you were filling the Id in hand, which makes no sense within this context. Place an uncharted text field in your Model in a database as…
-
3
votes1
answer6129
viewsA: How to send NFE XML by consuming the SEFAZ web service
SefazWebRequest possibly the result of the class generated by Visual Studio for this WSDL: http://nfe.fazenda.mg.gov.br/nfe2/services/NfeRetRecepcao2?wsdl In this answer I teach how to generate this…
-
4
votes2
answers3862
viewsA: Display dynamic images using Razor
This is the wrong way to return an image to HTML, since you are exposing a portion of your infrastructure in the code. What’s right is you make one Action just to return the image, sort of like…
-
0
votes2
answers865
viewsA: ASP.NET vNext in Apache
As of the date of this reply, there is still no vNext implementation for Apache. Possibly this can occur only in 2015, and that is if the Apache team wants to implement vNext for the server.…
-
7
votes3
answers667
viewsA: What are these attributes in the properties?
That’s the right name. Attributes, or in English, Attributes. Attributes has several functions: Define information about the class, property or method, which will be used at runtime; Add functional…
-
2
votes1
answer287
viewsA: MVC Helper Menu
I find this approach very complicated. You can use @Html.Partial which produces the same result with easier debugging: @model…
-
1
votes2
answers745
viewsA: How to concatenate Strings into a Linq query
You would have to derive the return list again, using the first record as referential and aggregating the systems: dataGridFiscalizacoes.ItemsSource = fiscalizacoesBaixadas .Distinct() .GroupBy(x…
-
3
votes1
answer1041
viewsA: How to create a Lambda expression with Group by and Order By
I see no need in your example of using GroupBy and OrderBy. Only the OrderBy does all the work. public static List<Escopos> EscoposCalCliente(int IDCalCLiente) { using (entidadesIUS entidades…
-
1
votes2
answers453
viewsA: Radiobutton or button to sort data
You can use a logic using jQuery, for example, to call a Action using GET. Something like this: public ActionResult Listar(String status) { var lista = contexto.Ocorrencias.Where(o => o.Status ==…
-
1
votes1
answer208
viewsA: Problem rescuing References from a query in Nhibernate Hasmany
You are Serializing a proxy as per this code in comment. There is nothing wrong with how the serializer solves the problem. The reduction of serialized properties is the focus of the issue:…
-
1
votes1
answer1524
viewsA: How to install SQL Server together with the C# application created?
It is possible. The procedure is quite large for an answer and can be found here. The tutorial explains how to embed an instance of SQL Server 2008 into your system installation. I believe it also…
-
8
votes4
answers542
viewsQ: Subsequent Calls in Ajax
I wrote a system in Web2py for a client, and he wants me to automate a procedure. I thought of using Ajax. The idea is the following: I have a list of companies. Let’s say, 50. I want the screen to…
-
1
votes1
answer136
viewsA: Additional settings for referencing . NET 4.0?
Try to assemble the Web.config with both runtimes: <configuration> ... <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"…
-
1
votes2
answers713
viewsA: How to instantiate primary key in another MVC class?
Just complementing @Renan’s response, in his modeling a Funcionario may belong to only one Projeto and a Projeto has several Funcionarios. In another interpretation of your question, you might want…
-
1
votes2
answers202
viewsA: Layout adjustment with elements that are automatically generated
This is a somewhat complex problem involving the application’s CSS. It is one of the problems that Bootstrap proposes to solve. Roughly speaking, what you need to do is the following:…
-
2
votes2
answers191
viewsA: Error Log Generation Aspects by XML
This is the correct way to log all application errors? There is no absolute and correct way to get the state of your application’s stack. This is one of the ways, and I found it very interesting how…
-
4
votes1
answer168
viewsA: What does Runtime dependencies of Objects mean?
The translation of Runtime dependencies of Objects in free scope would be something like "dependency of objects at runtime". It works as follows: In languages compiled as C++, the compiler has…
-
2
votes1
answer278
viewsA: Place where methods of interaction of CRUD with the bank in ASP.NET MVC should be
The methods of interaction with the database (Create, Update, Select, Delete) should be inserted in which part of the project? I thought about describing each of these functions within the Model…
-
0
votes2
answers626
viewsA: Encrypt ini files
Considering that my first response was much questioned, I am putting here another way to encrypt the contents of the file . ini used the algorithm TripleDES. The method TripleDES requires an…
-
7
votes1
answer1435
viewsA: What encryption is used by Asp.net Identity?
Uses a Function of Key Derivation, as specified by RFC 2898. The process is quite intricate and ensures a secure password. Coding: public static string HashPassword(string password) { byte[] salt;…
-
0
votes2
answers626
viewsA: Encrypt ini files
If this answer is not good enough, please check my other answer to this question, rather than being negative about the answer that served the author of the question and that may serve other people…
-
3
votes1
answer781
viewsA: Using the Signalr
The mistake means that chat is coming null in this assignment: var chat = $.connection.chatHub; By all indications, you have not done step 8 of the tutorial, which is to register on Global.asax, at…
-
3
votes1
answer361
viewsA: Always include records from the other table if the value of the related field is not NULL
What you want is a LEFT OUTER JOIN. There’s no need for the CASE precisely because the LEFT OUTER JOIN brings the record even if the association does not exist. SELECT tableA.numero, tableA.valor,…
-
6
votes1
answer2883
viewsA: What is the difference between Classic and Integrated in IIS7 Managed Pipeline Mode?
Classic mode (the only mode in IIS6 and older versions) is a mode where IIS only works with extensions ISAPI and filters ISAPI directly. Roughly speaking, ASP.NET is just an extension ISAPI…
-
2
votes1
answer3273
viewsA: Online SQL database for LOCAL NETWORK only, connect via c#
There are basically two alternatives to what you want: Creating a Localdb database and having the system access its MDF file; Installing an instance of SQL Server Express and putting your database…
-
2
votes2
answers290
viewsA: How to insert Entities, related to other existing ones, into the Entityframework?
Alternatively, you can select all desired entities through a context and make the association. For example: var minhasEntidades = contexto.EntidadesB.Where(e => e.Tipo == algumTipo).ToList(); var…
-
8
votes2
answers2487
viewsA: .gitignore delete all folders but one
Thus: # Ignore tudo: * # Exceto este diretório: !Library/nao_ignorar Library/ The rest will be ignored. If you need to not ignore more directories below this directory, you need to specify the other…
-
2
votes1
answer99
viewsA: Code First One to Many
There are some things wrong. I will discuss them one by one here. 1. Note primary keys with [Key] We know that the Entity Framework is smart enough to deduce the keys from Model, but I still…
-
3
votes2
answers103
viewsA: How to capture Assembly from classes that inherit from a single class
Thus: Type[] types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type type in types) { if (type.IsSubclassOf(typeof(ClasseBase))) { // Faça aqui o que você precisa. A classe encontrada está…
-
1
votes1
answer402
viewsA: Error saving data from a session in the database
I don’t remember saying that in another answer, but possibly the cause of the problem is this: var itemPedido = new ItemPedido(); itemPedido.Produto = design; // Aqui você definiu um Produto (e de…
-
3
votes1
answer741
viewsA: Manipulating Listview C#
In theory you can extract Items and make it a list: var lista = minhaListView.Items; Then you can search like this: var elemento = lista.FirstOrDefault(l => l.nome == "Fulano"); Altering:…
-
2
votes1
answer1435
viewsA: Save Request - ASP.NET MVC
I’m guessing, by displaying your cart, ItemPedido already have an ID filled by you. That is, there would be a change here: public ActionResult AdicionarCarrinho(int id) { Pedido carrinho =…
-
2
votes1
answer161
viewsA: Validation control Errormessage
Implementing the interface IValidatableObject: public class Request : IEntity, IValidatableObject { [Key] public int Id { get; set; } [Required(ErrorMessage = "O Centro de Responsabilidade é…
-
2
votes1
answer3350
viewsA: How to save a file to a field in SQL Server?
Using the column type FILESTREAM. Here is a tutorial on how to configure your SQL Server to use FILESTREAM. You can create tables with columns of files like this: CREATE TABLE MinhaTabela ( [Id]…
-
2
votes1
answer165
viewsA: Error trying to generate PDF file with the same name
Lacked force the Dispose() at the end of the creation of the document: PdfWriter writer = PdfWriter.GetInstance(doc1, new FileStream(ficheiroAbs, FileMode.Create));//Erro ocorre nesta linha…
-
0
votes2
answers958
viewsA: Nullreferenceexception in User Filter
From what I’ve researched, and from what I’ve seen of your code, [FiltroSessao] is running before you set the value of Session. There are two ways to solve: Change of: void…
-
6
votes1
answer1275
viewsA: How to save formatted text to database
In my projects, I note the HTML text field as follows in Models: [Required] [AllowHtml] [DataType(DataType.MultilineText)] [Display(Name = "Description", ResourceType = typeof(Resources.Language))]…
-
2
votes1
answer1270
viewsA: Prevent user from being logged in twice
1. Place properties on the user who controls whether he is logged in or not public class Usuario { ... public bool Logado { get; set; } pubic string SessionId { get; set; } public DateTime…
-
2
votes3
answers563
viewsA: Which application layer is aimed at processing the most extensive and complex business rules?
I believe it is not a class of the model layer because it is not a validation of data, but of processes. This line of reasoning is correct? It depends. In question you said the following: I’ve been…
-
0
votes2
answers2053
viewsA: List in each position, the employees who most had change of position
This answer goes to SQL Server. If you need it for another database, please indicate in the question. SELECT c.descricao, f.nome, h.qtd FROM ( SELECT cod_func, qtd = count(1) over (partition by…
-
7
votes2
answers3589
viewsA: Entity Framework 6 does not create database
First of all, your solution is outdated. You need an update of all the solution packages. Open the Package Manager Console and type in the following: PM> Update-Package There was some weird…
-
2
votes1
answer533
viewsA: How to make a lambda in?
From what you’re asking, I’m guessing that convertStringListaInt_Result should be something like this: public class convertStringListaInt_Result { ... public int number { get; set; } ... } The logic…
-
0
votes4
answers164
viewsA: Father class with the same responsibility of the daughter class
You can simplify for one class only: public class Item { [Key] public int ItemId { get; set; } public int? ItemPaiId { get; set; } public string Nome {get;set;} public decimal Valor {get;set;}…
-
1
votes1
answer1250
viewsA: Best way to work with XLS and XLSX files
I use a Nuget package called Exceldatareader: https://www.nuget.org/packages/ExcelDataReader/ The Github repository is here. An example: var stream = File.Open(filePath, FileMode.Open,…
-
1
votes1
answer520
viewsA: Layout does not appear in "_layout.cshtml"
Here is the mistake: <script type="text/javascript" src="@Scripts.Url("~/Scripts/jquery.unobtrusive-ajax.min.js")" ></script> There is no @Scripts.Url. Probably you tried to use…
-
2
votes1
answer677
viewsA: Problem storing decimal values in SQL Server
Check whether your Web.config has the following statement: <system.web> <globalization culture="pt-BR" uiCulture="pt-BR" /> ... </system.web>…
-
1
votes1
answer63
viewsA: Search function for Sql Server
Use LTRIM and RTRIM at each occurrence to avoid spaces as follows: select PPESSOA.EMAIL from PPESSOA where PPESSOA.NOME in ( ltrim(rtrim('ABNER FONTOURA C,RÊA')), ltrim(rtrim('ADAILTON PEREIRA DE…
sqlanswered Leonel Sanches da Silva 88,623 -
1
votes2
answers844
viewsA: CONSTRAINT that adds parameter to FOREIGN KEY?
There is a way using foreign key, but in this answer explain why this is not a good idea. The correct, as stated in the same answer, is for you to prevent direct manipulation of the data by the…
-
2
votes1
answer248
viewsA: Design standard or best practices for handling virtual disk files
Some of the practices cited below are from other Stack Overflow questions, and some are mine, by empiricism. There is no Microsoft best practice guide. This response should serve as a good guide to…
-
1
votes1
answer158
viewsA: Generate MAC address hash and save to database
It’s important that you don’t make this information easy for someone who’s trying to break your system, so this denomination is not a good one. Change to the following: public class Licenca { [Key]…