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
Post a Comment