c# - dynamic filters in asp.net mvc 4 -


i want this:

var list = db.respaldoes.where(x => x.type == "backup");  if (condicion1)     list.where(x => x.entity == "gielcjlt03");  if (condicion2)     list.where(x => x.activity_type == "0"); 

i don't know if possible, list filters never applied.

you try this:

var list = db.respaldoes.where(x => x.type == "backup");  if (condicion1)     list = list.where(x => x.entity == "gielcjlt03");  if (condicion2)     list = list.where(x => x.activity_type == "0"); 

initially list when clause, x => x.type == "backup", executed give initial list refer to. then, if condicion1 true, make second fitering , assign result list. there again have deffered execution. when list requested consumed piece of code executed -hence name deffered execution. same holds second condicion , on.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -