Posts by danspark • 429 points
22 posts
-
1
votes1
answer40
viewsA: Doubt Entity Framework Core
You don’t need your class names to be equal to table names, but you need to map the class to the table. Code example of OnModelCreating: protected override void OnModelCreating(DbModelBuilder…
-
1
votes1
answer85
viewsA: I cannot call an asynchronous method in the view
Use the second way to log out, but adjust your controller code to the following: public async Task<IActionResult> LogOff() { await HttpContext.SignOutAsync(); return RedirectToAction("Index",…
-
1
votes1
answer286
viewsA: Help with Decimal . Net Core 2.2 recording
The problem seems to be that your input type is text, when actually it should be number, with the Steps attribute: <input asp-for="Valor" type="number" step="any">…
-
1
votes2
answers163
viewsA: How to make an ASP.NET Core Post API without using MVC?
The problem is that you are sending a json object, but you are asking for a string in the method. If you want to receive an object, create a class with the Value property: public class Input {…
-
1
votes1
answer30
views -
0
votes2
answers48
viewsA: How to create a new object containing all the values of an initial object but adding new attributes in C#
You probably want to use a parameter in the constructor: public class Foo { public string Bar { get; set; } public int Bin { get; set; } // caso ainda não possua uma instância public Foo() { }…
-
0
votes2
answers203
viewsA: How to Split a List Proportionately 32%, 32% and 36%
I imagine you can solve it in two ways. Solution 1: Already knowing the amount of groups (in case, you know), you can solve with a foreach: List<Flor> flores = Flor.GetFlores(); var rnd = new…
-
1
votes2
answers65
viewsA: How to do a parallelism or asynchronous call in a lambda
Make use of the method Task.Whenall, an alternative, probably more recommended to deal with parallelism. One way to reformulate this code to run in parallel is like this (I removed the excess code…
-
5
votes1
answer164
viewsA: How could I reverse the way a foreach travels through the object?
With the extension method IEnumerable<T>.Reverse Example: // using System.Collections.Generic; // using System.Linq; IEnumerable<int> list = new[] { 1, 2, 3 }; foreach (var item in…
-
1
votes1
answer555
viewsA: ASP.NET Core Pagination - Pagedlist.Core
Make sure your project is referencing Assembly Microsoft.AspNetCore.Mvc.Core.dll The interface namespace is Microsoft.AspNetCore.Mvc.Infrastructure
-
-1
votes1
answer94
viewsA: Return object between screens - c#
The best way to solve your problem would be to add a new property in your class that is called, and depending on the DialogResult informed, whether or not there is content. Example: public class…
-
0
votes2
answers45
viewsA: Group select and return exact amount
Mount your IQueryable<T> before calling the method ToList() which will be converted to an SQL query that will probably run faster than a grouping within memory.…
-
0
votes1
answer82
viewsA: How to change dll from Reference with running application?
It is possible through a dynamic Assembly invocation: // caminho da DLL antiga var assembly = Assembly.LoadFile("caminho"); // tipo da classe desejada dynamic instancia =…
-
0
votes2
answers107
viewsA: Code-First Fluent API with complex classes in ASP.NET Core 2.1
The code provided was of no use, but from what the exception says, the problem is that you have specified names in the anonymous type (x => new { ClienteId = x.ClienteId, NumeroCpf =…
-
1
votes2
answers137
viewsA: Show Groupby List using Lambda in view. ASP.NET MVC
Change the model type to IGrouping<int, GaragemModel.Vr> that there will be no change in behavior and will fail to make a mistake.
-
1
votes2
answers103
viewsA: Transforms string to decimal within an object
If you are sending the CPF with the mask, at the time of the conversion it will not identify as a number, and since it is structured this way, remove the mask before sending to the API. public async…
-
1
votes1
answer54
viewsA: Validate date in editfor
Use the attribute System.ComponentModel.Dataannotations.Rangeattribute. Example: [Range(typeof(DataTime), "01/01/2001", "01/01/2020", ErrorMessage = "Data Inválida")] public DateTime Data { get;…
-
5
votes2
answers95
views -
1
votes1
answer80
viewsA: Doubt in inheritance c#
There may be a problem with your way of thinking. The way your code is structured, an Employee is also a Student. The concept of inheritance does not mean going from one stage to another, but rather…
-
0
votes1
answer31
viewsA: Converting Jobject with dynamic objects
Map the received JSON to a class and use the method Jsonconvert.Deserializeobject. public List<Resposta> Deserializar(JObject respostas) { var itens = new List<Resposta>(); foreach (var…
-
2
votes3
answers222
viewsA: Decimal problems in the SQL string
If you do not want the dot to be converted to comma, you can make use of the Numberformatinfo, setting the property Numberdecimalseparator. var valor = 100.5M; //decimal var formatter = new…
-
0
votes1
answer30
viewsQ: How can I remove the spacing between methods and properties?
I’m using the most updated Visual Studio 2017 Preview, and I’ve tried to uninstall and reset the settings, but this spacing remains independent of what I do. How can I remove this?…