c# - Filtering on a ProjectToList in LINQ -


i using mediatr request visualizationdto

public visualizationresponse handle(visualizationquery message) {     return new visualizationresponse     {         loadtick = datetime.now.ticks,         visualization = new visualizationdto         {             infeed = context.unloaders.projecttolist<infeeddto>(),             levels = context.levels.projecttolist<leveldto>()         }     }; } 

these mapped directly dbcontext. problem projecttolist<> maps recursively. in level there's list of buffers , in each buffer there's list of stacks. need map stacks have timeout value of null. don't want filter trough after mapping because might slow down things. , tried

var lq = context.levels; var stacks = lq     .selectmany(l => l.buffers)     .selectmany(b => b.stacklocations)     .where(s => s.timeout == null);  levels = lq.projectto<leveldto>().select(l => new {l, stacks}).tolist().select(x => x.l).tolist() 

but values receive aren't filtered ones still full dataset. there other ways filter on projecttolist?

right have output looks like

list<leveldto> -list<bufferdto>   -list<stacklocationdto>     -stack timein- timeout     -stack timein- timeout     -stack timein- null     -stack timein- null 

i need filter out stacks finished not have timeout of null.

the condition executed stacks not lq. try stacks.projectto<leveldto>(), should trick.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -