Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
5
votes2
answers144
viewsA: Is it redundant to use LIMIT in a QUERY whose ID is the primary key?
If the query uses the primary key as a criterion, yes, it is redundant. If the query uses as a criterion an index that is not the primary key and whose value is not unique, it may be, but not…
-
2
votes2
answers314
viewsA: Simultaneous tasks (Best way?)
But in all of them I had the same problem: not being allowed to manipulate an object from another thread and if I use the invoke method the application is very slow. Maybe you don’t know the concept…
-
1
votes1
answer276
viewsA: Error when putting Virtualbox as a service
There is a project called Vboxvmservice that does this service for you. Just install, change the file VBoxVmService.ini inside C:\vms and restart the service.…
-
2
votes1
answer2031
viewsA: How to list all files from a server directory in ASP.NET MVC?
That’s almost it. Switch to: DirectoryInfo diretorio = new DirectoryInfo(Server.MapPath("~/img/imagens/")); FileInfo[] arquivos = diretorio.GetFiles(); See more here.…
-
1
votes1
answer851
viewsA: How to check if a file is corrupted in c#?
One option is to check the CRC. There is a library called Damiengkit that implements Crc32. Example of use: Crc32 crc32 = new Crc32(); String hash = String.Empty; using (FileStream fs =…
-
0
votes2
answers1464
viewsA: I cannot read the values returned from the database using Oracledatareader
The approach by OracleDataReader possibly bring you problems in inspection. For your case, use only OracleDataAdapter as an example below: using (var cnn = new…
-
1
votes3
answers1235
viewsA: Problems with Data and Globalize
I believe my answer pointed out by you is outdated. This one should more specifically solve your problem. For the specific case of jQuery Validate and Globalize, you need to have a specific sort of…
-
3
votes2
answers1320
viewsA: Save user and password without database use
Yes, using Triple DES. This Codeproject article teaches you how to do. If you need me, I’ll put the code here, translated.…
-
1
votes1
answer58
viewsA: Class diagram and database design in Visual Studio online
Visual Studio Online does not have these features. Here is the list of resources up to the date of this reply. These features are usually even from Visual Studio Ultimate. There is also Entity…
visual-studio-onlineanswered Leonel Sanches da Silva 88,623 -
4
votes2
answers2482
viewsA: Repeat header in print
It is not possible to accomplish this without the help of a tool. HTML Renderer for Pdfsharp is an envelope for the Pdfsharp, and the Pdfsharp has the headboard and footer feature. If all else…
-
2
votes1
answer359
viewsA: Relating various data from one table to another with SQL
Some things that can be improved: Spell out weak junction (left outer join) This specifies that you are admitting that data does not always exist, which can happen. For example, a single person does…
-
4
votes1
answer1174
viewsA: Razor C# list and sublist with List<String> (originally "how to check if an HTML element already exists")
I’m guessing that Model is List<String>, then I can sort alphabetically and group the values by the first letter of each String: <ul> @foreach (var item in Model.OrderBy(s =>…
-
0
votes1
answer33
viewsA: Search for data not committed
The data appears because you possibly use the same connection that opened the transaction to query, so it is correct that they appear. In the Entity Framework, the transaction is not by connection,…
-
1
votes2
answers86
viewsA: Get the path of a commit files with Libgit2sharp
Apparently it’s comparing the previous commit tree to the current one. Here I found a fixture used in the project to test two trees that can help: public void CanCompareACommitTreeAgainstItsParent()…
-
1
votes1
answer640
viewsA: @Html.Actionlink submitting Post MVC form
No. There is a fierce confusion of concepts there. A form POST sends information from a form using the data submission protocol. Clicking a link is a request GET that sends information through the…
-
1
votes1
answer81
viewsA: Netframework dependencies in the project folder?
This is a fresh feature (on the date of this reply). It will be included in Visual Studio 2015 and is called Microsoft . NET Native. If it is older than Framework 4.5.2, it is not possible. You have…
-
2
votes3
answers757
viewsA: Error while updating data
This can’t be here: DbSet.Attach(obj); entry.State = EntityState.Modified; Or you modify the State of entry, or you make a Attach. The recommended is the first, ie: public void Update(TEntity obj) {…
-
4
votes1
answer652
viewsA: How to implement the MVC standard in PHP
The Wiki on the tag mvc can be a good starting point. MVC is a theoretical model, a design standard. There is this Sitepoint link that can serve as a tutorial for your case, in PHP. It’s a little…
-
3
votes1
answer1215
viewsA: Convert a file . pdf or . P7s to Base64 in C#
A generic Base64 file encoding code should solve: using (var fs = new FileStream("C:\\Caminho\\Do\\Arquivo.pdf", FileMode.Open, FileAccess.Read)) { byte[] bytesArquivo = new byte[fs.Length];…
-
6
votes5
answers838
viewsA: Is it possible to integrate GIT with some task manager?
Github has a list of known tools for integration. Since Github is basically a Git upgrade, you can consider these tools as possible to be integrated with any other Git flavor. Another tool that I…
-
1
votes2
answers53
viewsA: Check if directory is a repository with Libgit2sharp (C#)
Apparently the command is used git-ls-tree. If there’s something inside, it’s a repository: using (var repo = new Repository(dir)) { var tree = Repository.Lookup<Tree>("sha"); if (tree != null…
-
2
votes1
answer1630
viewsA: Monetary values with Asp.net MVC
Install the Nuget package in your application jQuery Money Mask. See examples of usage and configuration here. Avoid using @Html.EditorFor(). It does not allow mask or class addition because it is…
-
0
votes2
answers945
viewsA: Why can’t I update the framework?
Try installing these two packages: Microsoft . NET Framework v4.0 Microsoft . NET Framework v4.5.2 As the updates are cumulative, you can run both installers smoothly.…
-
2
votes1
answer33
viewsA: Static or Resource class?
If it is your wish that these phrases/words can be exchanged at some point, use Resource. It is the feature that was made for this, and the design pattern has several features that can be…
-
1
votes1
answer727
viewsA: Learn Asp.net without dominating c#?
It would be a bad deal to start with Asp.net and get the language c# as Asp.net advances.net? No, as long as you seek to acquire knowledge in C# as you study. That is, if a construction appears in…
-
0
votes2
answers1466
viewsA: Entityframework complaining of Identifier duplicity even with the property being null
Entity Framework does not work well when you define a foreign key directly, as in the case of Produto. The right thing would be something like: var produto = contexto.Produtos.SingleOrDefault(p…
-
3
votes2
answers868
viewsA: How does Entityframework’s Tracking / Chache work?
How, after all, does the Tracking of objects of Entityframework? First it is important to explain that a context exists during the life cycle of a Controller, in the specific case you are working…
-
1
votes1
answer440
viewsA: Take the file path opened by the process name in C#
Through the Process class it is possible to acquire the file path that is being worked? No. For this case, the approach needs to be another, using a . NET class called FileSystemWatcher. I have…
c#answered Leonel Sanches da Silva 88,623 -
2
votes1
answer124
viewsA: How to apply mask in these cases?
I’m guessing that CPF always has 11 numbers and CNPJ 14 numbers, and that the type of item.CPFCNPJDevedor is String: @if (item.CPFCNPJDevedor.Length < 14) {…
-
4
votes2
answers328
viewsA: Show white space for Null value in Views
Yes. Suppose, for example, that @model has a property called Numero which came void for some reason. Good practice for displaying the value is like this: @(Model.Numero ?? 0) This operator has a…
-
1
votes3
answers4174
viewsA: Recover larger and shorter hours conditioned on dates
If I understand the problem, only grouping by code can solve: select min(data_inicio), max(data_fim), min(hora_inicio), max(hora_fim) from minha_tabela where codigo = 2 group by codigo…
-
2
votes1
answer557
viewsA: Return to previous view with data filled in
Use GET instead of POST: @using (Html.BeginForm("Acao", "Controller", FormMethod.Get)) { ... } To Action who receives the POST must allow GET also: [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]…
-
1
votes1
answer647
viewsA: Problems authenticating to Report Service 2014 server via C# MVC5 application
Apparently the WebClient is not passing credentials to the Report Service. If I were you, I’d try access using HttpClient with HttpClientHandler to specify the authentication data in greater detail.…
-
0
votes1
answer387
viewsA: C#. Image.Getthumbnailimage increasing file size
Bit depth must be different. Windows default (currently) is 32 bits. Open the Bitmap specifying a bit depth: var bmp = new Bitmap(320, 320, System.Drawing.Imaging.PixelFormat.Format24bppRgb);…
-
1
votes1
answer241
viewsA: Convert Datatable to List Entity
The syntax is wrong. The generic usage statement is as follows: public static void SetItemFromRow<T>(T item, DataRow row) where T : class, new() { ... public static T…
-
0
votes1
answer548
viewsA: How to print a RDLC report on Asp.net
The Print button should call another aspx. In this aspx, you can do as follows: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ReportViewer1.ProcessingMode =…
-
1
votes1
answer1310
viewsA: JPA - Two Onetoone and Onetomany relationships between the same class
The way you are, your @OneToOne amid Estudante and PessoaFisica doesn’t make much sense, because not necessarily a person is a student, and a registrant shouldn’t be a student either. I would do…
-
3
votes1
answer112
viewsA: Plugin for Visual Studio to create javascript
Yes, the Web Essentials for Visual Studio. Use like this: <!-- #region Regiao --> @codigo <!-- #endregion --> I don’t know if there’s a shortcut to create religions, but here’s the tip.…
-
6
votes2
answers415
viewsA: Fluent API with ASP.NET Identity
Is there any contraindication in performing the class mapping IdentityUser manually? The recommended is that you keep the code on Assembly separately as close as possible to the original code of…
-
3
votes1
answer256
viewsA: Doubts about implementation of Lazy Load and Dependency Injection
If the idea is dependency injection, the ideal for your implementation is to use a Dynamic Proxy. The best link I know as an introduction is this. Since you already have the interfaces, the best way…
-
1
votes1
answer63
viewsA: Frameworks section of project.json
I know that now there are different versions of CLR that can be used, have the . NET complete and have the Core CLR that is lighter. But in this section there are basically "dnx451" and "dnxcore50"…
-
5
votes1
answer3970
viewsA: Pass a list of View objects to the Controller
The approach is correct. You need to modify some things: 1. The Partial should be created within the @Html.BeginForm This is because all address fields will be handled by form and included in Model…
-
6
votes2
answers1066
viewsA: Listview or Gridview in Windows Forms
What’s the difference between the two? ListView is a more complete component, with greater possibility of customization and support for native ordering. GridView is a simpler component, faster to…
-
3
votes2
answers4895
viewsA: Pass parameters to the Controller via @Html.Action
The parameter passed to the anonymous object has to be exactly the same in the signature of Action. See that: @Html.Action("ExibirCliente", "Cliente", new {idcliente = Model.ID}) The parameter is…
-
2
votes1
answer139
viewsA: Convert an XML file to BSON
I think it would be interesting to serialize your XML into a dynamic object first: public class XmlToDynamic { public static void Parse(dynamic parent, XElement node) { if (node.HasElements) { if…
-
7
votes2
answers169
viewsA: Expand Object to Bson
For this case, the ideal would be an extension method more or less like this: public static class BsonExtensions { public static BsonDocument ParaBsonDocument(this ExpandoObject obj) { var retorno =…
-
3
votes1
answer90
viewsA: Search all table fields in an Action
This is one of the classic problems of the service, that there is inadequate for the solution. Still, if your solution uses Entity Framework, which already implements a repository, it is even more…
-
1
votes1
answer557
viewsA: Windows Form: Microsoft Skin
We’re actually talking here about WPF. It would be a "Windows Form with vitamins". Not only the "skin" can be modified, but the whole theme. There is a project in Codeplex dedicated to this…
-
2
votes2
answers278
viewsA: Dynamic property in Static class
The most elegant way to do what you want would be to create an extension method for IPrincipal. User implements IPrincipal: public static class UserExtensions { private static Object threadLock =…
c#answered Leonel Sanches da Silva 88,623 -
14
votes1
answer6870
viewsA: Date problem with globalize.js and jquery.validation.globalize.js. How to resolve?
This is not a simple problem (it really consumed me the effort of a night to find out). The problem is the order of the js that needs to be respected: jquery.validate.js;…