Posts by Jéf Bueno • 67,331 points
1,254 posts
-
4
votes1
answer28
viewsA: Generate a Partial Model from a complete Model
There’s a lot of mistakes there. For starters. This query from s in db.Cliente_man where s.id_cliente == codCliente select new { id_cliente = s.id_cliente, nome_fantasia = s.nome_fantasia, Perfil =…
-
10
votes3
answers293
viewsA: How to know if class instance inherits another class?
Since you want to check the "parent" type from an instance variable of the "child" type, you can use the operator is. If you want to use the method IsSubclassOf, will need to make use of the method…
-
4
votes1
answer56
viewsA: Find the position of a letter using FOR
There are some things wrong there, but I’ll just focus on the crucial error of your task. This block of code if (Texto.Contains(Palavra)) { contador++; } checks whether the variable Texto contains…
-
3
votes1
answer133
viewsA: Delete multiple database elements
Before anything I need to say have a GET endpoint to remove a resource doesn’t make the slightest sense semantically. If you are using EF 6.0 or a newer version, you can use the method RemoveRange…
-
3
votes1
answer207
viewsA: How to convert a text to html
Instead of using the default interpolator, add two exclamation marks (!!) after opening the keys and before closing. {!! $textoHtml !!} See more on documentation of the Laravel…
-
3
votes1
answer1105
viewsA: Problem Injecting a Service into the Controller: An unhandled Exception occurred while Processing the request
If you want instances to be created automatically, you need to record any and all dependencies on them. This includes registering an instance of AEContext to be injected into what you call…
-
2
votes2
answers177
viewsA: Converting (Mapping) a List of an entity to another reference explitically
As long as the conversions are valid, you can use the extension method Cast linq. Considering the code of this answer, would look like this. var listB = listA.Cast<B>().ToList(); var listA =…
-
0
votes1
answer52
viewsA: NODE.JS server does not run
This is the expected behavior. To see the server working, open the browser and type in the address bar 127.0.0.1:3000. The console will only display something if a call is made from console.log. var…
-
1
votes1
answer64
viewsA: How to pass information in Viewdata on Asp.net core MVC
In the controller public class ProdutosController : Controller { public IActionResult Index() { ViewData["Informacao"] = "Alguma info"; return View(); } } In the view <span>…
-
5
votes1
answer40
viewsA: Undefined object reference for an instance of an object c#
The estate Tecnico of Leitora is null (default value). Initialize it before use Leitora leitora = new Leitora(); leitora.IdLeitora = tb_numserie.Text; leitora.DataEntrega = dp_data.Value;…
-
1
votes3
answers124
views -
4
votes1
answer246
viewsA: Selection with Dapper using IN clause
Just take out the parentheses. Dapper already does that. select * from product where CasNo in @filtro
-
2
votes1
answer170
viewsA: Javascript to enable button
Just wear the event change of checkbox to set the property value disabled button. const checkbox = document.querySelector('#chk'); const button = document.querySelector('#bt');…
javascriptanswered Jéf Bueno 67,331 -
3
votes1
answer58
viewsA: What is the difference between these two types of standard values?
In practice there is no difference. The default value for the property will be entered in the constructor call. However, analyzing the two generated IL codes, one can notice a brief difference…
-
2
votes3
answers73
viewsA: How to create a class with type inference that can have a default type in C#
You can create a class with the generic type "fixed". It is necessary to be careful because it opens gaps for someone to modify the derived class and it does not conform to the original. class Foo :…
-
24
votes1
answer3663
viewsA: Why does a return with status code 200 return before a 204?
The return 204 is pure convention, the code means a successful response with no content (body). The requisition OPTIONS itself is a "special" request made by the browser when you request resources…
http-statusanswered Jéf Bueno 67,331 -
5
votes1
answer866
viewsA: How to catch the current day
The basis for what you need is the DateTime.Today (or DateTime.Now, the difference between them is that the Now contains the time). This returns the current date, in an object of the type DateTime,…
-
1
votes1
answer119
viewsA: Configuration file save directory with User C#scope
Is not possible. This article talks a little about it. If you need the settings file in a separate location, you should write your own mechanism to manage it.…
-
3
votes2
answers691
viewsA: Limit the number of characters in a textbox
Check on the insertion itself. Incidentally, a tip: if you are going to do exactly the same thing on all buttons just by changing the text, it is possible to just set the property Tag of each button…
-
3
votes2
answers2252
viewsA: Unassigned variable in c#
Because if the code falls on else the variable will never receive a value. Just initialize the variable with the default value. double s, sn = 0; // ... Trying to read the code, it seems to me that…
-
1
votes3
answers277
viewsA: How to concatenate sublists from a list and add values to them using Linq with C#
You need to use the method SelectMany to do what you call "concatenate lists" and then group by item id and then sum the amounts. Thus var gp = estoques.SelectMany(x => x.Itens) .GroupBy(x =>…
-
4
votes1
answer52
viewsA: I’m trying to make a rollback of my Querys only to give me a mistake in Executescalar
The error says the command (instance of SqlCommand) needs an associated transaction. Note that one of the constructors receives three parameters: the SQL string, connection and transaction. What you…
-
3
votes1
answer35
viewsA: Show a fk name on the grid
Change public virtual int Cidade { get; set; } for public virtual Cidade Cidade { get; set; }
-
0
votes3
answers283
viewsA: How to break line after 29 digits C#?
You can do using LINQ For example: using System; using System.Linq; public class Program { public static void Main() { string strText = "1234567890" + "ABCDEFGHIJ" + "1234567890" + "abcdefghij" +…
-
5
votes3
answers80
viewsA: How to deal specifically with a Keynotfoundexception?
You can simply use the method TryGetValue. This method attempts to get the value by the given key and, if the key does not exist, returns the type pattern. string idFormaPgto;…
-
2
votes2
answers316
viewsA: GIT no new or changed files remote location
Whenever a commit is required to report a message. git commit teste -m "arquivo teste"
-
7
votes2
answers95
views -
10
votes2
answers753
viewsQ: What does the exclamation mark mean after a guy’s name?
I have seen a lot in Kotlin types marked with an exclamation mark at the end. Especially when I use Java’s API. Something like CharSequence! What does that mean?…
-
5
votes2
answers3129
viewsA: How to assemble a Restrequest with x-www-form-urlencoded in Restsharp C#
Is similar. Just need to change the header and add each key-value pair with the method AddParameter. request.AddHeader("content-type", "application/x-www-form-urlencoded"); //...…
-
2
votes2
answers93
viewsA: How to disable a Qlineedit in Pyqt?
You can use the method setDisabled of QWidget. QLineEdit inherits from this class. inputUserName.setDisabled(True)…
-
2
votes1
answer1167
viewsA: Unable to load type'<Projectname>. Mvcapplication 'when duplicating project
Open the Global.asax.Cs file and fix the namespace to be in line with what is in Global.asax namespace Siteteste2 { public class MvcApplication : System.Web.MvcApplication { protected void…
-
4
votes1
answer32
viewsA: Nullreferenceexception in C#
This is because the customer list has not been instantiated. I have no way of knowing what is the right time to instantiate it, but if it is right at startup you can do right at the declaration…
-
3
votes1
answer52
viewsA: C# MVC project launching Exception System.Invalidcastexecption
You are just adding vendor names to Combobox. It makes no sense to want to convert the SelectedItem for the guy Fornecedor because combo items are only strings. There are several ways you can fill…
-
10
votes1
answer275
viewsA: Error in java second degree equation algorithm
The delta calculation is wrong, it must be currently stands as Note that the last message It’s not a second-degree equation is being shown always, I imagine that some validation of when to show it…
-
2
votes1
answer194
viewsA: Entity Framework Code-First - Automaticmigrationsenabled
Yes. You open the Package Manager Console and type Update-Database This will generate a new migration automatically and update the database.…
-
2
votes2
answers186
viewsA: type’T' must be a Reference type in order to use it as Parameter 'Tentity' in the Generic type or method
The mistake happens because the Constraint of the method Set asks the guy T (the type the method expects) is a type is reference (where TEntity : class). Put an interface on Constraint does not…
-
4
votes1
answer133
viewsA: Check/Uncheck button check box
Missing you remove and add the Handler in the uncheck event as well. Without this the code makes no sense. private void desmarcar(object sender, EventArgs e) { DataTable table =…
-
2
votes1
answer846
viewsA: Change color only of the clicked element (Angularjs)
There’s nothing wrong with your code, at least not with the basis of it that was posted here. Make sure to be closing all the tags, to be using the variable isActive only within the loops and that…
-
4
votes1
answer653
viewsA: Visualg algorithm: disregard number 0
Only add a criterion in the condition: If the number not zero (is other than zero) and if the remainder of the division by 2 is equal to zero. Just to leave a few hints: watch out for code…
-
4
votes2
answers375
viewsA: Select element based on the data-id attribute
You can use the document.QuerySelector with the selector data-id='2'. This function will return an element that meets the selector, if there is no element that meets the condition will be returned…
-
5
votes1
answer88
viewsA: Find the largest number in a text file
You can read the file lines in a much easier way using File.ReadAllLines(). This method will read the file and create a array where each line in the file represents an element in the array. After…
-
5
votes1
answer101
viewsA: Build error: Name 'x' does not exist in current context
You have to remove the semicolon after the for for(int i = a; i <= b; i++); // <<-- Isso tá errado It must be so: for(int i = a; i <= b; i++) { if(i % N == 0) { Console.WriteLine(i); } }…
-
4
votes2
answers490
viewsA: How to use anchor in Angularjs?
This probably has nothing to do with Angular, only the # in the href. See working: html { scroll-behavior: smooth; } div { width: 90%; height: 120vh; background-color: red; } .blue {…
-
0
votes1
answer311
viewsA: MD5 Asp.net MVC encryption
The problem is in this line of code if (db.Usuarios.Any(x => x.Usuario.Equals(model.Usuario) && (verifyMd5Hash(x.Senha, model.Senha)))) More specifically, in the second line. Because, how…
-
6
votes1
answer69
viewsA: How to split a Datetime-like column from an Entity Framework query?
You have to use the support function DbFunctions.TruncateTime. To use this function you need to pass the DateTime complete, not the member Date DbFunctions.TruncateTime(x.Data)…
-
1
votes1
answer91
viewsA: C# - Asqueryable - Condition (Linq - Lambda)
Just use the method Where with the predicate Status, as its value is a boolean do not need to compare with another boolean. var regras = ctx.ConsultaIntramexRegras.Where(r => r.Status) .Select(p…
-
6
votes5
answers2296
viewsA: What good is a C#?
It is a modifier that, in classes, defines that other classes cannot inherit from the specified. public class A { } public sealed class B : A { } // Funciona normal. B herda de A e não pode ser…
-
1
votes3
answers674
viewsA: how to count integers in c#
You can use LINQ. Make a code simple, readable, enjoyable and enjoy the free time to go for a coffee. Read this answer to understand how the method works GroupBy, in it has everything explained and…
-
10
votes2
answers1340
viewsA: What good is a Viewmodel in ASP.NET MVC?
In C# everything needs a type. Well, currently it is even possible to work more dynamically, but it is not the point. Types are defined by classes. In ASP.NET MVC it is customary to type the views…
-
5
votes3
answers328
viewsA: Check if the value is contained in Range Jquery/Javascript
The variable range is not a crease, is a array with two values. Therefore, it is only necessary to make a common comparison operation. To include extremes use >= and <=, otherwise use < and…
javascriptanswered Jéf Bueno 67,331