Posts by Marco Souza • 12,304 points
506 posts
-
1
votes1
answer135
viewsQ: Message Warning CS0108!
Because when I inherit an interface and implement the same methods I get Warning CS0108. Active A variable was declared with the same name as a variable in a base class. However, the new keyword was…
c#asked Marco Souza 12,304 -
8
votes1
answer67
viewsQ: What is the difference between Class and Code File on Asp.net Core?
What is the difference between Class and Code File in Asp.net Core? There are two types of files in Asp.net core, there is some difference between one and the other? And when we should use each?…
-
0
votes1
answer79
viewsQ: How to make an Annotation data validator based on another field?
I’m trying to implement a validator based on another field. My class of domain. [Required] public string _tipoDeControle { get; set; } [NotMapped] public TipoDeControle TipoDeControle { get { return…
-
6
votes1
answer200
viewsA: Search for people with similar names
You can specify the end of the name inside the brackets. declare @pessoas table ( id int, nome varchar(100) ) insert into @pessoas values (57,'Victor Sousa dos Santos'), (57,'Vitor Souza Santos')…
-
0
votes3
answers870
viewsA: How to pass a value from one method to another method within the same class ? C#
You are doing some unnecessary things in your method. public void CadastroDespesas() { string descricao; float valor; float soma = 0,tot; Console.Write("Informe o valor: "); valor =…
c#answered Marco Souza 12,304 -
0
votes2
answers925
viewsA: Current Date in @Html.Editorfor() Asp.Net MVC
The Best place for you to make the correction is in the constructor of your model. public class Sequencia { public Sequencia() { DataSequencia = DateTime.now(); } [Key] public int SequenciaId { get;…
asp.net-mvcanswered Marco Souza 12,304 -
1
votes1
answer44
viewsA: Like the Entity Framework Trackeia objects?
When you read a database object the Entity Framework maps property by property and it sets a state (States) for each property, so he knows any changes that occur with the object. There is still the…
-
3
votes2
answers3799
viewsA: Load a Dropdownlist based on an Enum - Asp.net core
You can create a class static and manipulate their Enum to popular his SelectListItem public static class ExtensaoDeEnumerador { public static string GetEnumDescription<T>(string value) { Type…
-
0
votes1
answer114
viewsA: How to Save Data Console Application using Entityframework
If you’ve created your own Dbset, you can create a simpler CRUD with the Entity Framework. See how it would look. public class ContatoRepositorio : IContatoRepositorio<Contato> { protected…
-
0
votes5
answers371
viewsA: Validate model before inserting in the database
Apart from the accepted answer, there is still the class Validationresult that could be used to validate your object. var resultado = new List<ValidationResult>(); var contexto = new…
-
2
votes1
answer792
viewsA: Entity lambda framework with include returns empty Collection
You can create multiple selects including your tables as follows. var data = _context.Forms .Select(f => new { Forms = f.Forms, OrganizationUnit = _context.OrganizationUnit.FirstOrDefault(x =>…
-
2
votes3
answers195
viewsA: Select with detailed like
It’s no secret. Select * from suatabela where seucampo like '%OSIVAN SOUSA%'
mysqlanswered Marco Souza 12,304 -
1
votes2
answers347
viewsA: Ninject Not creating the Ninjectwebcommon class
The latest version of Ninject.MVC5. Changed and no longer create the NinjectWebCommon in the App_Start, instead you have to change the file Global.asax.cs inheriting the NinjectHttpApplication.…
-
1
votes1
answer153
viewsA: Doubt Interface Asp.net mvc
You need to know to want to server the Interface, The methods form the object’s interface with the outside world; the buttons on the front of your television set, for example, are the interface…
-
0
votes3
answers558
viewsA: List Categories with Subcategories of the same table with another table
You need a relationship with nw_manuais_tecnicos_categorias and between itself to returns the category FATHER. Take the example. select m.id_manual , m.titulo , m.arquivo , m.downloads ,…
-
0
votes1
answer61
viewsA: Fluent api - Map table to another table with the same key
See the example of how you can do. public class ImportacaoHeader { public string IdImportacao { get; set; } public DateTime dataInicio { get; set; } public ICollection<ImportacaoLog>…
-
2
votes1
answer412
viewsQ: How to replace string using another string containing Json?
Is there any way to replace a String with the fields of another string that contains a Json? Example; I got the string; String template = "Olá [Nome], Tenha um bom dia ... hoje é [Data] e é seu…
-
1
votes3
answers393
viewsA: Sort children in consultation Linq
I would summarize it all in. public Grid GetByOrderGridData(long id) { var grid = (from c in context.Set<Grid>() where c.Id == id orderby c. select c ).FirstOrDefault(); if(grid != null) grid…
-
0
votes2
answers146
viewsA: How to associate items from a String list to the code name of a C#label?
In his string[] letras = new string[numletras]; for (int i = 0; i < numletras; i++) { letras[i] = palavra.Substring(i, 1); } You need to pass the value for each label14.Text, That is to say.…
-
1
votes4
answers96
viewsA: What is the best solution ? Getbyid with a non-existent id in the BD
The problem of using the Single is that it launches into the database a Top 2, and if there are two records for the past filter it returns an error and if no record is found it also returns an…
-
2
votes1
answer379
viewsA: Convert SQL to LINQ
Mounting the sql query to Line would be translated into the form below. Contexto.Set<ultimaposicaorastreadores>() .Where(x => x.DataGps ==…
-
1
votes1
answer2907
viewsA: Select to count quantity per column
You need to Use Max and Min to get the dates of the maximum and minimum groups the Equipment and use the having to check which are with quantity greater than 1 that will be repeated. select…
-
1
votes1
answer53
viewsA: When there is no string specification with the configured class where the Entity Framework creates the tables
Where is my data? By default EF uses Localdb, if you did not specify for the Dbcontext constructor which was the conectionstring it probably did this. By convention, Dbcontext create a database for…
-
1
votes2
answers1406
viewsA: SQL Server - Changing information in a text field (REPLACE does not work)
See if it helps. declare @MYTABELE table ( id int, orgsalkeyfil text ) insert into @MYTABELE values(1,'INFO:Alfa,Beta,Gama;CPPC-TM:0x3453;ALGOMAIS'); UPDATE @MYTABELE SET orgsalkeyfil =…
-
1
votes2
answers56
viewsA: Query SQL Server - Union
Try to make another select. select Consultor, UsuID , sun([Tentativa 1 Abertos]) From ( select U.UsuNome Consultor, U.UsuID, (COUNT((S.SolID))) AS [Tentativa 1 Abertos] from Solicitacao S left join…
-
2
votes2
answers2574
viewsA: LINQ using function inside select new{} with lambda Expression
EF cannot interpret methods that are not tracked by it. One way around this is by writing your function within your own query. IQueryable<ImoveisDTO> Resultado = ctx.Imoveis .Select(ib =>…
-
0
votes1
answer1060
viewsA: DOUBT ABOUT SUBSELECT IN FIREBIRD
You don’t need a Subselect for that, just use the CASE SELECT CASE WHEN OPERACAO = '+' THEN SUM(DINHEIRO) END SaldoEntrada, CASE WHEN OPERACAO = '-' THEN SUM(DINHEIRO) END SaldoSaida, (CASE WHEN…
-
1
votes3
answers455
viewsA: LINQ with JOIN and Where clause, how to do?
using(Entities banco = new Entities()) { List<PESSOASFJ> listapessoa = (from pes in banco.PESSOASFJ join nf in banco.NOTAFISCALCAPA on pes.IDPESSOAFJ equals nf.PESSOASFJ into GrupoNF from b in…
-
0
votes1
answer44
viewsA: How to Create an N:N Table where one of the keys does not belong to a table of the same database
As you do not have one side of your template you will have to treat as 1/N, and map the ID of the other table. I don’t see any other way to do that, unless you have the whole model.…
-
1
votes2
answers88
viewsA: What is the Creation proxy for in the Entity framework?
At first I see no purpose (benefit) at all, unless you want to work in an environment that does not need a tracking or want to do it manually. A point that could be useful would be a case that you…
-
2
votes2
answers123
viewsA: Help with LINQ, query no . Net
Try using the Line as follows. var query = (from _NFESAIDA in _contexto.NfeSaida join _NFESAIDA_ESTACAO in _contexto.NfeSaidaEstacao on _NFESAIDA.NfesaiSequencia equals…
-
1
votes1
answer36
viewsA: NOT EXISTS usage in 2 subquerys
I believe your problem is in your sub select.. You need to list your table tb_pedidoproduto with the tb_produto this inside the sub select and only then check if the ids are equal AND…
-
0
votes4
answers288
viewsA: Error with vectors c# / {"Object reference not defined for an instance of an object." }
if (v[i] != null)//MEU TRECHO PESQUISEI QUE TALVEZ SOLUCIONARIA O ERRO Certainly this missing you declare the size of your vector, the error may not even be this, but it is most likely with the…
c#answered Marco Souza 12,304 -
0
votes1
answer99
viewsA: Error while trying to save data to two tables at the same time
Surely this is happening because its object ConsBritadorPROD is already in context, when you do the Find in his method SalvarHistorico it is loading in context and mapped. ConsBritadorPROD…
-
3
votes3
answers436
viewsA: error saving or updating with Entityframework
I don’t see any reason for you to use the BeginTransaction, you are trying to save a single object if something wrong happens to it then nothing will be changed in the bank, there is a reason to use…
-
1
votes3
answers119
viewsA: Object is not persisted when using Entity Framework
The way you are trying to do it is in a disconnected senario, that is, your context has no knowledge of your object that you are trying to persist, so you need to teach the walk of the stones to it.…
-
1
votes1
answer460
viewsA: Can the Crosscutting layer recognize my Dominion layer?
Yes. Let’s understand the concept. Cross-Cutting is an editing technique most often used in films to establish actions occurring at the same time in two different locations. In a cut, the camera…
-
4
votes1
answer272
viewsQ: How to create default filters with Entity framework 6?
I have an Excluded field in several classes and when I will make my select I always have to impose this condition in the query, is there any way to make the filter implicitly? recalling that it is…
-
0
votes2
answers190
viewsA: In Development Code First how do I relate the Aspnetusers table to other tables
I didn’t really understand what you need, a relationship 1/M is made with the ; public virtual ICollection<SuaClasse> SuaClasse{ get; set; } in the table that has the relation 1/M I believe it…
-
0
votes2
answers1207
viewsA: Left Join with three or more lambda tables
Ever tried to make. var result = (from de in ctx.tbDescricaoEstado join c in ctx.tbCidade on de.idCidade equals c.idCidade into c1 from c2 in c1.DefaultIfEmpty() join e in ctx.tbEstado on…
-
5
votes2
answers195
viewsA: LINQ query with sum
You can create a select with your filter before the final select. As you commented I will not change your Where, but the solution would be like this. var dados = _db.Contratos .Where(a =>…
-
7
votes1
answer1172
viewsA: How to use Automapper 6.2.2 in Asp MVC5?
I will demonstrate an example using the category class and the viewcategoriamodel... using System; using System.Collections.Generic; using AutoMapper; using LojaVirtual.Aplicacao.Interfaces; using…
-
0
votes1
answer89
viewsA: In a MVC 4 C# Web Application model, in which layer can the ADO.NET Entity Data Model file be located?
In a well structured project the layer responsible for data access stay in the Infra.Data. You can use the DDD to create an application by following a software modeling approach. See the full…
-
0
votes0
answers95
viewsQ: Error saving data with EF
I am assembling my unit tests and trying to save the data in a table using the Entity Framework, but at the time I run it returns an error. Validation failed for one or more entities. See…
-
0
votes0
answers253
viewsQ: Ninject - System.Missingmethodexception: No constructor without parameters has been defined for this object
I’m in the wrong; No constructor without parameters has been defined for this object. Description: An untreated exception occurred during the execution of current web request. Examine stack tracking…
-
1
votes1
answer55
viewsQ: Error in application Asp.net mvc
I have the error below and do not know how to solve. Does anyone have any idea what to be and how to solve? Severity Code Description Project File Line Suppression State Error Unable to copy file…
asp.net-mvcasked Marco Souza 12,304 -
3
votes3
answers679
viewsA: Entity Relationship Framework 1:N
You can use a sub select to include the sale items. public IEnumerable<Vendas> GetVendas() { using (Contexto ctx = new Contexto()) { return ctx.Vendas .Select(x => new Vendas { Id = x.Id,…
-
0
votes1
answer117
viewsQ: How to load Textboxfor after onchange of a Dropdownlistfor?
How can I load a Textboxfor after choosing a Dropdownlistfor element? I load the Dropdownlistfor with a list and from that list I want to filter an object to load the balance according to the…
-
3
votes2
answers30215
viewsA: how does auto increment work in mysql?
You have to set the value AUTO_INCREMENT initial for your table. ALTER TABLE users AUTO_INCREMENT=3509; If you haven’t added an identification column yet, add it ALTER TABLE users ADD id INT…
-
2
votes2
answers838
viewsA: Select picking up previous line
A little big, but it solves your problem.. declare @Velocidades table ( Speed int, Data Datetime, Alerta int ); insert into @Velocidades values (58,'2017-09-13 10:08:04.290',44), (20,'2017-09-13…