I use Linq for my queries and want to get a list of properties that I want to return in the "select" section using reflection. I tried the following to no avail:
string[] paramList = new[]{"AppId","Name"}; var query = from entity in _ctx.App select new {entity.GetType().GetProperties().Where(prop=>paramList.Contains(prop.Name) )};
What am I missing here?
When working with reflection inside an EF request, you will need to write the expression yourself. Look at this existing question for more information.
Linq, , , Entity Framework .
, , , , . , ( ) . , , - select ( API- , System.Linq.Expressions), , , Select() ( , ).
System.Linq.Expressions
Select()
, , , - , , , .
, ?
Source: https://habr.com/ru/post/1787825/More articles:Необходимо преобразовать рекурсивный запрос CTE в индексный запрос - sqlЛучший способ заполнить пробелы в многомерном массиве в Ruby - arraysPantheios is part of the C ++ DLL - c ++how to put a ringtone on an android emulator - android-emulatorHelp with CTE recursive access to second table - sqlAdding arrays without copying duplicate values in C # - arraysHTML5 API - Availability and Features - html5Find percentage value in string using preg_match - phpHow to reflect T to build an expression tree for a query? - reflectionHow to dynamically access an object? - actionscript-3All Articles