c# - How to pass a func<> in linq to sql with a join -


i have following issue.

i want pass func parameter can vary in statement.

   private ienumerable<user> getuser(int cant, func<user, bool> userfilter, func<client, bool> clientfilter)     {         return (from dcu in                     _db.all<user>().where(userfilter)                 join c in _db.all<client>() on dcu.idclient equals c.idclient temp                 cli in temp.defaultifempty().where(clientfilter)                 select new {usuer = dcu, client = cli}).             take(cant).select(uc => _usersmapper.map(uc.user, uc.client)).asenumerable();      } 

and func should this

    public void getusers ()     {         getuser(50, u => u.email.contains("onemail@mail.com"), c=> true);     }     public void getusersfilterbyclient ()     {         getuser(50, u => true, c=> c.password.contains("mypasssword"));     } 

you need lambda where filter function:

private ienumerable<user> getuser(int cant, func<user, bool> filter) {     return (from dcu in _db.all<user>().where(a => filter(a))             join c in _db.all<client>() on dcu.idclient equals c.idclient temp             cli in temp.defaultifempty()             select new {usuer = dcu, client = cli}).         take(cant).select(uc => _usersmapper.map(uc.user, uc.client)).asenumerable(); } 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -