Questions tagged as 'linq'

2
answers

LINQ using function within select new {} with lambda expression

I am assembling a select, with the Entity Framework, that needs to "create a column" according to 4 criteria. I'm trying this way: IQueryable<ImoveisDTO> Resultado = ctx.Imoveis.Select(ib => new ImoveisDTO { idImovel = ib.idImovel...
asked by 04.01.2018 / 13:04
1
answer

Use DefaultIfEmpty in a LINQ query with Join

The purpose is to join these two lists, and if in the pr list you have an item that does not match the un list, the default value is returned. I know there are other ways, however, I'd like a solution using DefaultIfEmpty...
asked by 04.01.2016 / 01:38
1
answer

Query Linq with count

I am making a query that has some joins and a count, however I want to do it with Linq . This is my Query. sbSQL.Append("SELECT grproj.cdgruproj as Id, grproj.dsgruproj as DescricaoGrupoProjeto, "); sbSQL.Append("(SELECT...
asked by 06.04.2015 / 16:31
1
answer

Return Join Linq C #

I'm trying to return a join for my class and it's giving me the following error    Error 1 Can not implicitly convert type   'System.Collections.Generic.List' in   'System.Collections.Generic.List' C: \ Projects \ ASP.NET \ AdvanceTechniques...
asked by 19.08.2014 / 15:36
1
answer

Use Contains in an integer field in C # with lambda or LINQ

I have the following expression: query = query.Where(x => x.MeuCampoInteiro.ToString().Contains(filter)); But an exception is occurring: System.NotSupportedException: 'The expression [10008].MeuCampoInteiro.ToString() is not supporte...
asked by 27.09.2017 / 16:43
1
answer

How to simplify the type declaration with Entity Frameowrk?

I have some tables with several fields of type datetime, and for all of them I need to create a validation in OnModelCreating () for this type, that is, I need to set .HasColumnType("datetime"); , my doubts are; Is there a more practical...
asked by 24.11.2016 / 13:59
2
answers

C # Windows Forms Generic Object

I have a Desktop application in C # and need to load a dropdown with an "All" option and the rest coming from a database table. To load the dropdownlist I did something like this: cmbOpcoes.Items.Add(new { Id = 0, Name = "Todos" });...
asked by 12.05.2016 / 00:13
1
answer

Object reference not set to an instance of an object when trying to retrieve an element in an XML file

I have a bug tormenting me. I'm basically saving the settings of all devices (RF Readers) in an XML file (Configs.xml). My goal is to retrieve the first element from all settings that has a "set" value (other than "") in the newLoot attribute...
asked by 20.10.2015 / 21:45
2
answers

Simplify LINQ p = p.Type.ToUpper (). Equals ("S") && p.Mode.ToUpper (). Equals ("S") ..., n

How to simplify the LINQ expression? p => p.Tipo.ToUpper().Equals("S") && p.Modo.ToUpper().Equals("S")...,n     
asked by 05.10.2015 / 23:50
1
answer

Name editing is confirmed in the database but does not occur in the list

I am editing a database column and so far everything is fine, but when I load the table that contains this column using Include, it simply does not update the " Driver ", ID in the relationship but in the listing continues the name of the old re...
asked by 10.06.2015 / 22:07