I have in Database table Users:
pk firstName lastName
1 Mary Snow
...
LINQ to Entities create class:
public partial class User
{
public int pk { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
}
I tried to create new part of this class
public partial class User
{
public string FullName
{
get
{
return lastName + " " + firstName;
}
}
}
And after i tried to use it in IQueryable i get exception "The specified type member 'FullName' is not supported in LINQ to Entities". Can i create property or extension method for this?
I need it in many parts of my code. And it is not comfortable for me use in every query lastName + " " + firstName. I don't understand why i can use in IQueryable "where(x=> (x.lastName + " " + x.firstName) == "Mary Show")" but i can't write new property and use it as "where(x=> x.FullName == "Mary Show")".
It is example in really i have more modifications of fields.
upd: I use .NET Framework 4.5.2 and Entity Framework 6.
upd2: I use Database-First approach.