c# 4.0 - Create Func<T,Bool> At runtime -


i have 2 classes: role , customrole

public class customrole {     public string rolename { get; set; }     public int roleid { get; set; } }  public class role {     public string rolename { get; set; }     public int roleid { get; set; }     public int myrole { get; set; } } 

at compile time have delegate this:

func<customrole, bool> del = o => o.roleid > 0; 

the problem @ runtime need create 1 more delegate same condition table name changed

func<role, bool> del1 = o => o.roleid > 0; 

how can achieve this?

you have both role , customrole implement irole interface includes ruleid property, make delegate use irole.

if not option, duck typing.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -