Posts by Barbetta • 5,587 points
191 posts
-
4
votes1
answer64
viewsA: How could I sort a list of records, from a certain attribute of my class in C#
To sort a list you can import the namespace System.Linq and use the OrderBy or the OrderByDescending, it will return an ordered list, exemplifying: var listaOrdenada = ListaEmpregados.OrderBy(p=>…
-
18
votes1
answer201
viewsQ: What does _ in C#mean?
I was servicing a system until I came across the following code: object auth; var authContext = HttpContext.Items.TryGetValue("SystemQueryContext", out auth); var result = await…
-
2
votes1
answer52
viewsA: How to make Git case sensitive?
Exists the configuration core.ignorecase You can use it as follows: git config --global core.ignorecase [false|true] It is possible to check more on documentation…
-
2
votes1
answer81
viewsA: How to pass an Enum type parameter together with the Model for a Partialview - Asp.net Core MVC
It is necessary that the cast of ViewData because he doesn’t know that inside it contains a PessoaTipo. Your line of code should be like this: PessoaTipo pessoaTipoRecebido =…
-
1
votes1
answer268
viewsA: Registration with Modal and Partialview . Net Core 2.2
As a comment, so that the Submit it is necessary that it be inside the form. It is also necessary in your form indicate the action. @model HelpDesk.Models.Fornecedores <div class="modal fade"…
-
1
votes3
answers652
viewsA: Web API does not return JSON
One option is to remove the SupportedMediaType XML public static void Register(HttpConfiguration config) { //Outras Configurações config.Formatters.XmlFormatter.SupportedMediaTypes…
-
5
votes2
answers484
viewsA: How to hide property in Efcore listing
You can ignore a property to be serialized by decorating it with the JsonIgnore public class Profissional { public string Nome { get; set; } public string Cpf { get; set; } public string Endereco {…
-
1
votes1
answer291
viewsA: Ignore Automapper property
You can ignore properties with .ForMember(p => p.Propriedade, x=> x.Ignore()) Thus remaining: CreateMap<Contrato, ContratoDto>().ForMember(p => p.Descricao, x=> x.Ignore()); In an…
-
2
votes3
answers144
viewsA: Return last contributor who checked the car
I rode a query however, it may be necessary to do some validations to see if it works in all scenarios. It was not clear to me one thing, if collaborator 33 check the car 3 times, theoretically he…
-
4
votes2
answers134
viewsA: EF Core - Pass parameter with integer list
You don’t need to wear one query SQL if you are already using EF. public List<Pedido> GetByUsuario(List<GestorVendedor> gestorVendedor) { return _dbContext.Pedido.Where(p=>…
-
1
votes2
answers1064
viewsA: Visual Studio opening multiple browser windows
It is necessary to change two settings for this, being them: Tolls>Options>Debugging || Tools>Options>Debugging 1) Uncheck "Enable Javascript debugging for ASP.NET(Chrome, Edge and IE)"…
-
0
votes1
answer199
viewsA: How to read an XML that is inside the project?
It is necessary to inform the wwwroot folder on the way to that of sure. , your code should be like this: var xml = System.IO.File.ReadAllText(@"wwwroot\MenuXML\menuV11.xml"); I take the opportunity…
-
1
votes1
answer31
viewsA: C# Spire.Xls set list of workbooks
You can believe a list as follows: Using the namespace System.Collections.Generic has the List<>, in it is possible to define a list of some kind, in your case Workbook. Finally, to add items…
-
3
votes1
answer62
viewsA: Doubt with Viewdata using Asp.net core 2
As the message says "The type or namespace name 'Student' could not be found", the Student type or namespace could not be found. To use an object within the view it is necessary to either put the…
-
0
votes1
answer28
viewsA: I am doing a search system in my movie view and gave an error regarding the Web request
At the beginning of his view When you declare her type, there should be a list of the object. Change of @model WebApplication3.Models.MovieViewModel[] for @model…
-
0
votes4
answers474
viewsA: Grab part of a string
You also have the option to use LastIndexOf with the Substring. Where do you indicate startIndex and the size you want to take from string string texto = "Ninguem ninguem, todos"; string…
-
3
votes1
answer62
views -
4
votes7
answers1103
viewsA: Remove part of string until nth occurrence of a character
Among so many alternatives, I made one more, I did not validate its efficiency in relation to the others, but it follows anyway: string dados = "0001>0002>0003>0004>0005"; //string dados…
-
11
votes4
answers3477
viewsA: Press button with keyboard enter key
Below a way using Jquery: Knob: <button type="reset" id="btnFecharJanelas" class="btn btn-primary btn-sucesso" onkeypress="fecharJanelas('ListaBancos')"><i class="far…
-
1
votes4
answers1003
viewsA: Problem saving a change using Entity Framework
Turns out you’re filling out the property UnidadeMedida but not the UnidadeMedidaId. Leave your code more or less like this: public ProdutoViewModel Atualizar(ProdutoViewModel produtoViewModel) {…
-
13
votes1
answer338
viewsQ: What is Leaky abstraction (abstraction leak)?
I was listening to a podcast and the term arose Leaky abstraction. The example given is something like this: A system uses a relational database and has a generic class for data access, at a given…
-
6
votes3
answers1590
viewsA: Check that all fields of an entity is null
Well, I’d like to start by saying I don’t know if that’s the best way to do it, but you can use it Reflection, goes below: bool TemAlgumaPropriedadeComValor(object myObject) { foreach (PropertyInfo…
-
1
votes3
answers271
viewsA: I can’t do addiction injection
Two injections are missing for your code to work correctly, 1º of the Repository and 2º of your context, your code should be as follows: public void ConfigureServices(IServiceCollection services) {…
-
6
votes1
answer38
viewsA: List contents of a list with a method
You are probably not able to pass as a parameter because the class is not published. I changed your code to the following way: I also adjusted the names of the properties, in C# we used Pascal Case…
-
1
votes3
answers458
viewsA: How to Update to Linq?
You can do it this way: [HttpPost, ActionName("Delete")] [ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(int id) { Pessoas pessoas = db.Pessoas.Find(id); pessoas.Status =…
-
1
votes1
answer86
viewsA: "Jsonresult" does not contain a constructor that accepts 0 arguments
No. Net Core does not have the option JsonRequestBehavior it is managed by the attribute that sits on top of the IActionResult, in your case you already inform that it is a Get with the HttpGet.…
-
1
votes1
answer2136
viewsA: Download File on Asp net mvc
Nothing happens because you are trying to download via Ajax, another way to solve this would be to open a new blank window to download, for this just change its function Javascript to the following:…
-
2
votes2
answers100
viewsA: Razor language regionality
An alternative is in your model to use the Annotation DisplayFormat, below an example: public class Modelo { [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")] public…
-
1
votes2
answers320
viewsA: I want to create a Python calculator with constructor, but when I create an object it says that the class is not defined
It turns out that the object instance is inside the class, just return the indentation class Calculadora: def __init__(self, numero1, numero2): self.numero1 = numero1 self.numero2 = numero2 def…
python-3.xanswered Barbetta 5,587 -
2
votes2
answers234
viewsA: Selectedvalue error of a dropdownlist in ASP.NET
Turns out when you give a Postback in the application it goes through again Page_Load and recharges the DropDownList, to avoid this use the if(!IsPostBack){}, it will check if it is the first time…
-
9
votes2
answers994
viewsQ: What are side effects?
I was reading that reply and it has a table where it says that functional programming has no side effects and that OOP has, it generated me two doubts, being them: What are these side effects? Can…
-
3
votes2
answers91
viewsA: System.Nullreferenceexception sending Form Asp.Net MVC
As I mentioned in the comment the problem was that you had a property called filial and his action received an object with name filial, this caused it to get lost. one option is to rename the…
-
1
votes2
answers862
viewsA: No parameterless constructor defined for this Object
Missed you record the injection of dependency of the IAppService, your code would look something like this: public static void Initialize() { var container = new Container();…
-
2
votes1
answer156
viewsA: Jsonconvert.Deserializeobject returns null
As stated in the commentary of Roberto the Json is a Array, however, should not have this public Class1[] Property1 { get; set; }, leave your class like this: public class TaxDocument { public…
-
6
votes3
answers3659
viewsA: In Trigger we have INSERTED and DELETED. Why not "UPDATED"?
If the Trigger for INSERT, INSERTED will have records and DELETED will be empty If the Trigger for DELETE, INSERTED will be empty and DELETED will have records If the Trigger for UPDATE, INSERTED…
-
0
votes2
answers305
viewsA: I can’t write data to my firebase
It turns out you are changing the data in the wrong location. In the Firebase there is a new option called Cloud Firestore, which is selected by default (see image below), but That’s not where you…
-
0
votes2
answers96
viewsA: Change a Generic Repository method to return with Asnotracking - EF Core
Based on that response from the OS. The Method Find() does not possess the AsNoTracking(), but you can change his status to Detached, which is the equivalent. Your code would look something like…
-
0
votes1
answer65
viewsA: Where it doesn’t work when listing all records - Entity Framework
Missed the ToList(). It turns out that the IQueryable it just creates the query, it will actually run when you "indicate" it with the ToList() or a FirstOrDefault(), for example. To check for value,…
-
7
votes1
answer1373
viewsQ: What is Feature Driven Development (FDD)?
I was researching about BDD, TDD and DDD and came across FDD (Feature Driven Development), after all: What is FDD? It has some relationship with BDD, TDD and DDD?…
-
2
votes2
answers85
viewsA: Dropdownlistfor with Viewbag and Dictonary returning null value
As I mentioned in the comments on the other answer, the problem occurs when it returns to View after the validation of the data to ViewBag is not loaded with data. In the Code below extracts the…
-
2
votes2
answers62
viewsA: Change the end of the email domain to a random scan
You can do it like this: UPDATE pessoa SET email = CONCAT(substring(email, 1, (LEN(email) - CHARINDEX('.',REVERSE(email))) + 1), LEFT(REPLACE(CAST(NEWID() AS VARCHAR(36)), '-', ''),…
-
2
votes2
answers733
viewsA: ASP.NET MVC Entity - Scaffolding for more than one table simultaneously
Supposing in your model, in the class PessoaFisica own a property Contato, you can add everything at once, so the Entity will handle the transaction for you in case of an error in one of the…
-
1
votes1
answer464
viewsA: How to add include by expression in Repository Pattern C#
I do it this way: public virtual List<TEntity> SelectIncludes(Func<TEntity, bool> where, params Expression<Func<TEntity, object>>[] includes) { IQueryable<TEntity>…
-
0
votes1
answer48
viewsA: Edit screen does not load data on screen
Missed to return the object to the View, your code would be more or less like this: public async Task<ActionResult> EditVM(int id) { GetFuncionarioAsync funcionario = new…
-
0
votes1
answer121
viewsA: Pull Attribute setName from another class in the Agenda view using the Idservico foreign key with Razor Asp.Net mvc
You selected the list with the services but did not return it, switch to the following: public ActionResult Index() { var agendas = db.Agendas.Include(t => t.Servico); ViewBag.IDServico = new…
-
2
votes1
answer37
viewsA: How to choose (depending on login) which master page to run?
As the error says, to tell which Masterpage to use, use the event Page_PreInit protected void Page_PreInit(object sender, EventArgs e) { //Sua Logica Aqui this.MasterPageFile =…
-
0
votes2
answers202
viewsA: Model error on Razor page
Missed the treatment to see if already values in Model, it is coming null, so NullReferenceException Your View it may be so: @model IEnumerable<TreinamentoCrud.Models.Cidade> @{ ViewBag.Title…
-
1
votes1
answer42
viewsA: Delete api not working, do not delete. Stored Procedure in the database is working
Has two problems, i) the command SqlQuery is to return entities, in case you are trying to execute an action. ii) is not being informed the variable after the `Procedure. change to:…
-
0
votes1
answer786
viewsA: Error Saving Data - Nullreferenceexception: Object Reference not set to an instance of an Object
You’re getting a NullReferenceException because when the Post is not charging again your DropDownsList's, the code of Action CreateOrEdit in the Post it should be something like this: [HttpPost]…
-
1
votes1
answer437
viewsA: Load table via AJAX
Turns out you’re returning a Json not the table html. Change your code as follows: function buscaFornecedores(id) { var url = "/Produto/BuscaFornecedor"; $.ajax({ url: url, type: 'GET', data: { id:…