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