Posts by Gustavo Santos • 870 points
38 posts
-
2
votes1
answer105
viewsA: Include in Entity Framework from an Enumerable
Yes! Possible! Just use Theninclude: var query = _context.Rota .Include(r => r.CidadesRotas) .ThenInclude(r => r.Cidade) .Where(r => r.RotaId == RotaId); It may be that your Intellisense…
-
0
votes2
answers96
viewsA: Change a Generic Repository method to return with Asnotracking - EF Core
The find method makes no sense to be used with Asnotracking, since, by its description, it is informed that it is first checked whether the object is being tracked: Finds an Entity with the Given…
-
2
votes2
answers100
viewsA: Doubt with the language C#
There’s another way to do the same: string palavra = "palavra"; string palavaComEspacos = string.Join(" ", palavra.ToCharArray()); Console.WriteLine(palavaComEspacos); In this solution, the result…
c#answered Gustavo Santos 870 -
2
votes1
answer140
viewsA: Object Reference not set to an instance of an Object - MVC
You are not giving include: change the entities' loading line to: var produtoempresa = await db .ProdutosEmpresas .Include(p => p.ProdutosEmpresas) .Where(p => p.ProdutoID == id)…
asp.net-mvcanswered Gustavo Santos 870 -
0
votes1
answer100
viewsA: How to use a padleft(11) in a get in the API
You need to create an employee Viewmodel with the same properties of the entity, but in this Viewmodel Cpf will be string type. In the method GetFuncionario you need to map the Employee entity to…
-
3
votes2
answers219
viewsA: C# - Initialization of an array/list
You can use a workaround to create this array with the following instruction: Enumerable.Range(0, 100).Select((y) => -1).ToArray(); Note that there is an overhead to do this, but it solves what…
-
1
votes1
answer33
viewsA: When I delete the model name is not shown
You see, you are deleting the city already, and if you want to show some data from that city, you need to have two Delete methods, one GET (to show the city information) and one POST (to confirm the…
-
2
votes1
answer107
viewsA: I’m not getting a list of an API
In your controller’s Index, change the return of the method to a Task<ActionResult> and use the await to await the return of the method GetCidades, because this method returns a Task and not a…
-
0
votes1
answer43
viewsA: Conversion of Types with Fluenti API to EF Core 2.1
You need to create the conversion via lambda, the first, is the parse of the bool for char, the second, of char for bool (used when loading from the database) public class PessoaMap:…
-
0
votes1
answer44
viewsA: Maps in . NET CORE, Fluent API - property . Hasforeignkey with error
The problem is in your Categoriabarco class, as it is a 1:N ratio, your class does not need to have the Barcoid property, because if it does, it means that you are saying that Categoria has only one…
-
2
votes1
answer47
viewsA: How to merge sublists from a class and return the result using Linq and C#
To return only one list, use the Selectmany method: return orders.SelectMany(x => x.ProductSolds).ToList(); Example no . Netfiddle by colleague Rovann Linhalis: Example…
-
2
votes1
answer198
viewsA: Redirect Actionresult
This happens because the attribute ChildActionOnly is making this Action Menu cannot be accessed other than through a View daughter and blocking the redirects (as the error message itself says), it…
-
0
votes1
answer491
viewsA: How to display messages (Summay) to the user in the Index view
Alternatively, if successful, redirect to the index by adding the message in Tempdata, and access this variable in the index with an if. [HttpPost] [Authorize(Policy = "CanWritePessoaSituacaoData")]…
-
0
votes1
answer122
viewsA: Error while Updating using Entityframework Core
Friend, when you search for some database record with the Entity, it is saved in a framework cache, (it is saved a reference of the object), however, when we update an object, the ID is the right…
-
2
votes2
answers234
viewsA: How can I get the Insert in log with logged in user ? Identity - Asp.net core 2.0
In your Startup class, in the Configuraeservices method, check if there is a line like this, if it doesn’t exist, add: services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); In…
-
2
votes2
answers473
viewsA: Change value select via ajax as another select with static data
You must create an Event Listener for the change of the first select, put an ID in your select and include the script: $("#selectId").change(function(){ //Pega o value da opção selecionada let…
-
0
votes1
answer69
viewsA: Problem with Razor
In your Startup class, the Irepository interface must be set to Singleton, switch to Scoped or Transient. This is because the Applicationdbcontext class is as scoped, ie an instance is created by…
-
0
votes1
answer610
viewsA: Fill date Automatically in ASP.NET MVC 5
The most "clean" way to send a default value to the form, is to create an instance of the object and popular with the default values when giving the GET in the form ACTION: public IActionResult…
-
1
votes2
answers38
viewsA: Render css when transforming view into string
CSS files are not loaded in emails, the way to style an email sent with HTML is inline style or, load a style tag (in the same email string) with all classes and then use the classes.
-
0
votes3
answers135
viewsA: MVC: parameter in URL is not being passed to controller
Friend, first, to call this action, it must have the Httpget attribute to access this way with the href of a button. Second: to pass this parameter to the action, use the button as follows: <a…
-
3
votes1
answer2161
viewsA: Type an array of type any[] at angular 6
The ideal is to always type, you are on the right track, if you follow your JSON, you have to have these classes: export class Operation { error: boolean; items: Array<Item[]>; message:…
-
3
votes1
answer1146
viewsA: Error While Creating Migration
If you are using the Entity Framework in . NET Full, you need to have a constructor without protected parameters. If you are using the Entity Framework Core, it is possible to have constructors with…
-
0
votes1
answer1488
viewsA: Receive http client request status and login token at the angle
First, in your Auth.service.ts class, add the import: import { map, catchError} from 'rxjs/operators'; After that, change your auth.service.ts fazerLogin(email: string, password: string):…
-
0
votes2
answers172
viewsA: Scroll Element of the WPF C#Datagrid class
Datagrid has a property called Scrollviewer, in it you can add the scroll event (Scrollchanged) and has several properties: Contentverticaloffset, and several others related to size and vertical…
-
2
votes1
answer71
viewsA: innerHTML does not display Object
When you give the append to prtContent, use prtContent.outerHtml WinPrint.document.body.innerHTML += prtContent.outerHTML;
javascriptanswered Gustavo Santos 870 -
2
votes2
answers186
viewsA: Take select description - AJAX
To get the text of the selected option: var texto = $("#mySelect option:selected").text(); To play this for the controller, change the date object to: data: {id: x, text: texto}, Add the additional…
-
0
votes1
answer164
viewsA: Error when deleting record with Entity Framework when mapping entity
My question is why the error occurs when I try to delete the record using Mapper return ? When you load the database objects with the Entity Framework, these objects are cached by reference. So when…
-
1
votes1
answer41
viewsA: Promises - this.fileLoad..then is not a Function
You need to call the function with parentheses, this.fileLoad(). then(...
javascriptanswered Gustavo Santos 870 -
2
votes1
answer153
viewsA: If inside the button
The most correct is to make the logic to create two different buttons: @if(Model.Quitado){ <a onclick="alert('Conta já recebida')" class="btn btn-sm btn-warning" disabled>Receber</a> }…
-
1
votes1
answer524
viewsA: Simple C# MYSQL connection problem
In your string Connection is ssl:true, switch to Sslmode=required And in the password field, use PASSWORD=\"\" string caminho =…
-
0
votes2
answers1868
viewsA: Grab URL and skip to the next page
A possible output: When calling Action /Contareceber/Create, pass an additional parameter called returnUrl, which is the current URL: In your Startup class, in the Configuraeservices method, add the…
-
2
votes1
answer1468
viewsA: How to submit a post request using Xios and Asp.net Core Web API?
It seems your JS is correct, but you need to enable the CORS in its application .NET Core, in your class Startup, in the method ConfigureServices, add: services.AddCors(setup => {…
-
1
votes2
answers295
viewsA: How to create an array with results obtained through an observable<any[]> TYPESCRIPT
An observable is just a statement of your query to a service, for you to actually have access to that observable data, you need to give a subscribe. let prdn = queryProd('batata');…
-
0
votes1
answer428
viewsA: Save return service variable in Angular
You can do it like this: let suaVariavel = JSON.stringify(data);
-
0
votes1
answer132
viewsA: SQL command blocking controller requests in C# MVC
The Store will block the other requests of the database, on your machine it works because the database must have a smaller size, already in production the size of the database should be bigger,…
-
0
votes2
answers406
viewsA: What is the purpose of the Interfaces used in a Mock?
Mock simulates the functionality/data of a class, so that the library can create this fake class, it uses the interface to implement the class with the parameters you pass, thus, the library can…
-
3
votes1
answer236
viewsA: How to solve this diamond inheritance problem
Today, this is not possible in the language, however, in version 8 of C#, it will be possible to have the default implementation of methods in interfaces, anyway, one of the interfaces should be…
-
1
votes1
answer63
viewsA: When injecting a controller dependency, Postman returns error
You need to declare this Ioptoutservice dependency in the Configureservices method of the Startup class. services.addScoped<IOptOutService, SuaImplementacao>();