namespace FuncTypeMapper { public class User : IEntity { public int ID { get; set; } } public class DbUser { public int userId { get; set; } } class Program { static void Main(string[] args) { // Trying to get a user with ID 3 Func<User, bool> entityQuery = u => u.ID == 3; // However, the Linq type for user account don't contain property // ID for user, it has userId instead // so we need to convert the System.Func into DB compatible query Func<Func<User, bool>, Func<DbUser, bool>> queryConverter = f => f.????????????; // How to solve the above with C#??? // Then we could just convert the query Func<DbUser, bool> dbQuery = queryConverter.Invoke(entityQuery); // Before we Invoke it against the database var usersFromDb = from u in dc.UserAccounts where dbQuery.Invoke(u) select u; } } }
int
Func<User,bool>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)