Posts by George Wurthmann • 4,415 points
170 posts
-
0
votes1
answer200
viewsA: Why does ngx-mat-select-search not work with my dynamic data?
I’ll share the solution here that I got along with Eduardo Vargas' tip in the comments. I was able to solve my problem by following the instructions of macjohnny, of that Raid on Github. Briefly,…
-
1
votes1
answer200
viewsQ: Why does ngx-mat-select-search not work with my dynamic data?
I installed the ngx-mat-select-search and followed the example of Stackblitz. The example worked perfectly, just as it is in the stackblitz. After that I changed my code to load the data…
-
1
votes3
answers15292
viewsA: VARCHAR2 field boundary size in Oracle
The answer accepted for the question is correct and the documentation has a lot of information, but I will give a practical example because I have suffered enough with this oracle. Let’s start by…
-
1
votes2
answers1062
viewsA: Add-Migration does not work on EF Core 3
In the Static method 'Createhostbuilder(string[])' was found on class 'Program'. See the line above. You have this method in Program? Probably it’s like below: public class Program { public static…
-
0
votes1
answer36
viewsA: What use is the Viewstate?
Not much to explain. A documentation good explanations on the ViewState and there is other content with examples and explanations. Basically it stores data that can be used after a PostBack. In your…
c#answered George Wurthmann 4,415 -
2
votes2
answers121
viewsA: How to format decimal numbers using Fluent API in the Entity Framework?
Use the HasPrecision: public class EFDbContext : DbContext { protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder) { modelBuilder.Entity<Class>()…
-
2
votes2
answers75
viewsA: Get specific value in a txt file
With regex could do so: using System; using System.Text.RegularExpressions; using System.Linq; using static System.Console; class MainClass { public static void Main (string[] args) { var…
-
2
votes1
answer101
viewsA: Birth date validation with LINQ
First, for you to understand why the error occurs, you cannot use the Convert.ToDateTime() or the Convert.ToInt32() in a IQueryable. This is because the LINQ to Entities does not recognize these…
-
2
votes4
answers1049
viewsA: Changing HTML does not reflect on page - Asp . NET Core 3.0
This is an option from the Visual Studio IDE, not a language feature. To enable go follow the steps: Open the menu Tools > Options (en: Tool / Options) Click on the option Debugging (en:…
-
2
votes2
answers2067
viewsA: Merge two lists c#
Use the Addrange: List<VW_PARCEIROSOFERTAS> bdofertas = new List<VW_PARCEIROSOFERTAS>(); bdofertas.AddRange(bdofertasPrazo); bdofertas.AddRange(bdofertasValor); The collection whose…
-
1
votes1
answer85
viewsA: Change default pages created by MVC in Visual Studio C#
I wonder if there is any way that these pages always use a custom mode. Yes, there is. You can use T4 Templates Visual Studio to customize automatic generation of Views of a specific project. The…
-
1
votes1
answer1235
viewsA: Input Mask Razor
Use the .change of JQuery to make the mask change when switching options in the list. $("#doc").mask("999.999.999-99"); $('#docType').change(function () { if ($('#docType option:selected').val() ==…
-
1
votes1
answer47
viewsA: Why can’t I map using Automapper?
In the excerpt below you are mapping three times the same destination element and the last one he is assigning is the s.ContatoViewModel.IDCliente. CreateMap<ClienteViewModel, Cliente>()…
-
1
votes1
answer1099
viewsA: Oracle - WHERE WITH SYSDATE
The return of SYSDATE depends on how the NLS_DATE_FORMAT, the format should be different and the comparison is failing. See an example below: SELECT SYSDATE DATA1, --o retorno aqui depende do…
-
1
votes1
answer81
viewsA: Viewmodel is NULL when performed a Submit in the Main View - Asp.Net Core MVC
PessoaViewModel comes null because at no time she was instantiated. You can solve this by instantiating in a builder: public class FilialViewModel { public FilialViewModel() { PessoaViewModel = new…
-
1
votes1
answer285
viewsA: Error with modal using Partialview Asp Net Core 2.2
Your PartialView is using the model of View by default: @model IEnumerable<HelpDesk.Models.Fornecedores> This is because you did not inform the second parameter of the method Html.Partial and…
-
0
votes1
answer45
viewsA: Decode does not work
It is returning like this due to the 1252 encoding you are using: 1252 Windows-1252 Western European (Windows) Use the UTF-8: string requisita = new StreamReader(response.GetResponseStream(),…
-
2
votes1
answer66
viewsA: Default value in Select List . net Core 2.2
You can do it this way: <div class="form-group col-md-2"> <label>PA</label> <select class="form-control" id="PaId" asp-for="PaId" asp-items="ViewBag.PaId"> <option…
-
0
votes1
answer519
viewsA: Redirect Http to Https on IIS
Test use this setting on Startup.cs: var options = new RewriteOptions().AddRedirectToHttpsPermanent(); app.UseRewriter(options); Reference:…
-
2
votes1
answer1672
viewsA: Show current date and time (real-time clock)
What you want to do can’t be done with the .net. You want a real-time clock so you have to run on client for the browser and not on servidor. You can even recover the current date from your server…
-
0
votes1
answer49
viewsA: How to upload images(several) to the Asp.net database
Readbytes returns byte[], therefore in the allocation line of arqImagem.Imagem error when you change this property to IEnumerable. public virtual byte[] ReadBytes (int count); But there are more…
-
2
votes2
answers151
viewsA: How to create Function in Database with Migrations Ef core?
Use the add-Migration and personalize the migration. Sometimes it is useful to add a migration without making changes to template. In this case, adding a new migration creates code with empty…
-
2
votes1
answer81
viewsA: Return lambda value and not lambda mounted query
The problem is that when you called the .ToString() the query had not yet been executed, if you put a .ToList() (or .FirstOrDefault() if you do not expect a return list) before it you will solve:…
-
1
votes1
answer236
viewsA: Foreach in a Viewbag is not working properly
You didn’t specify the type of ViewBag. Change your foreach so that it stays as below: @foreach(var dominio in ViewBag.Dominio as List<MicrosoftCustomer>) {…
-
0
votes1
answer52
viewsA: Date Input returning Time along with date
Move your property to string in his ViewModel. public string dtNascimento { get; set; } If she’s the type Datetime it will always request date and time. In the model it can and should be of the type…
-
1
votes1
answer100
viewsA: Error while trying to render a partial view in a view
The answer is in your error message: The model item passed into the Dictionary is of type 'System.Int32', but this Dictionary requires a model item of type…
-
1
votes1
answer369
viewsA: Deserializeobject
Leandro is correct in the comment o main is as simple object: "main":{ "temp":15.7, "temp_min":15.7, "temp_max":15.75, "pressure":1021.33, "sea_level":1021.33, "grnd_level":996, "humidity":98,…
-
0
votes1
answer153
viewsA: Is there a reference for system.web in Asp.net core 2.1?
No, the system.web is not part of . Net Core. You can check in that catalog. The equivalent in . Net Core @LINQ already responded in the comment:…
-
1
votes1
answer819
viewsA: Cannot Create an instance of the Abstract class on interface 'Httprequest'
You are confusing System.Web.HttpRequest of .Net Framework with the Microsoft.AspNetCore.Http.HttpRequest of .Net Core. The second is an abstract class and as the error informs, you cannot…
-
0
votes1
answer38
viewsA: Builder is coming empty
Remove the empty constructor from your controller: public HomeController(){} When Dependency Injection is applied correctly, it is important that each type has only one constructor - multiple…
-
3
votes1
answer269
viewsA: Update-database -script in EF Core
Utilize script-migration after rotating the Add-Migration, this way it will generate the file SQL for you. You can also use the parameter Verbose next to the update-database to see the script that…
-
1
votes1
answer498
viewsA: Identityuser Password Change - Aspnet
Just use the method ChangePasswordAsync. In the ASP.NET Core use that way: ApplicationUser appUser = db.Users.Find(userId); var result = await UserManager.ChangePasswordAsync(appUser,…
-
2
votes1
answer85
viewsA: C# Wpf Passwordbox want to spy the password
With the PasswordBox cannot do. Maybe you can even do some "workaround" with TextBox using two of them where one actually stores the password and the other puts only '*' with each character typed,…
-
1
votes1
answer77
viewsA: How to store and display time only? C# Mysql
How to store and display time only? To store only time in Mysql you can use the type TEAM specific to this, as reported in the commentary. There is no error in the part where you convert the date to…
-
1
votes1
answer141
viewsA: How to take an image in a folder at the root of the project?
Use the HttpContext.Current.Server.MapPath string path = HttpContext.Current.Server.MapPath("Content\dist\img\avatarPadrao.png"); It is necessary to add the reference to the System.Web to use it.…
c#answered George Wurthmann 4,415 -
2
votes1
answer50
viewsA: Entity Framework, code First, Database query
If you want to use the Lazy Loading just change the classes like this: Client class public int Id { get; set; } public virtual Anamnese Anamnese { get; set; } Anamnesis class public int Id { get;…
-
1
votes1
answer443
viewsA: How to put a List<> in a Listview?
Assuming you have a class with the following properties: public class Veiculos { public int idVeiculo { get; set; } public string Fabricante { get; set; } public string Modelo { get; set; } } Then…
-
3
votes1
answer217
viewsA: How to use denial in Contains c# with LINQ?
Make a method that converts the value and if it is null, return 0 or -1, for example. public static decimal TratarDecimal(object valor) { decimal result; if(decimal.TryParse(Convert.ToString(valor),…
-
0
votes2
answers33
viewsA: Url in jquery is being mounted wrong
You have already solved your problem, but there is an important tip: when passing the parameter to the url called in ajax you can use the option data: In your example it would look like this:…
-
1
votes1
answer62
viewsA: Print a list according to the number of labels
As comments, start by correcting the division. Using Math.Ceiling you can divide by rounding up: int nrEtiquetas = (int)Math.Ceiling((double)Lista.Count / 5); The code so far would look like this…
-
3
votes1
answer251
viewsA: Error running Entity Framework
Your mistake is in app.config. Place the element connectionString inside configuration: <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime…
-
2
votes1
answer200
viewsA: Undefined object reference for an object instance. '
You must set the connection to the OleDbCommand. You have already set it in your code, but when initializing did not use the OleDbConnection to create the command: _oleCmd = _olecon.CreateCommand();…
-
0
votes2
answers168
viewsA: Mask-Money does not work on input array
There is no syntax error in your code, it will add the Mask in the Ids found in the inputs, in case the ones that were defined by you: #valor_unitario and #desconto See the example below:…
-
3
votes2
answers86
viewsA: Error saving BD change in C#
The ideal is to do the Insert as in the example below: MySqlConnection conn = new MySqlConnection(connString); conn.Open(); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = @"UPDATE Pacote…
-
3
votes2
answers144
viewsA: Clear html content with jquery not working
The problem is that your div is empty, the content you want to replace is out of it, so the content is duplicated when it comes from partialView. For the content of partial to be replaced do as an…
-
1
votes1
answer44
viewsA: Enter a screen with the dropdown option already selected
You can use a simple Jquery like this: $("#GrupoDescontos").val("Valor_a_Selecionar"); If you bring that kind of value ViewBag: $("#GrupoDescontos").val('@ViewBag.Valor_a_Selecionar'); See an…
-
2
votes2
answers518
viewsA: How to group a list of objects and after the grouping, get the list of objects that have the lowest value in c#?
With LINQ it’s that simple: var novaLista = listaDeProdutos.OrderBy(o => o.Valor).GroupBy(x => x.Nome) .Select(x => x.First()).ToList(); See the example working in your code. Basically what…
c#answered George Wurthmann 4,415 -
0
votes2
answers319
viewsA: How to scroll through an enumerable list and check if the property repeats in the list during foreach turns
I don’t quite understand what you mean by this, but you yourself have noticed this as you put it in your question. I say this because you may have N repeating groups. For example: Id 1, Date…
-
0
votes1
answer383
viewsA: Modal to delete Registry (.net core - javascript - Bootstrap)
How did you not give as much information as the name of controller and details of view, I’ll use a few examples assuming what you might be using. Put a ID on your confirmation button modal: <a…
-
1
votes1
answer47
viewsA: Access to EF Core data
I have a table with many fields, I am using EF Core for access, it is possible to return only the fields that I will actually use? Assuming you have the following entity: public class MinhaEntidade…