I want to use ExecuteQuery() to get IEnumerable of type Entities.UserLevel. Following code works well.
using (CDataContext context = data.GetDataContext())
{
string q = "SELECT *FROM UserLevel";
IEnumerable<Entities.UserLevel> res = context.ExecuteQuery<Entities.UserLevel>(q);
}
public class UserLevel
{
public int userID { get; set; }
public int levID { get; set; }
}
But the problem is that I must use property names in UserLevel class same as in database, otherwise I do not get values. I wonder is there any way to get values irrespective of class/property name? For example, I want to use following UserLevel class instead of above:
public class UserLevel
{
public int UserIdentity { get; set; }
public int LevelIdentity { get; set; }
}
Sure just write.
But why not use Linq instead? You could write:
You would need to create your own DTO class.