Reputation: 2589
Im getting the error"specified type member FullName is not supported in LINQ to Entities" when using select d.FullName, is it because it is not part of the table?
How do I fix this?
Thanks
USER CLASSpublic partial class tblUser
{
public tblUser()
{
this.Equipment = new HashSet<tblEquipment>();
}
public int ID { get; set; }
public string Forename { get; set; }
public string Surname { get; set; }
public string FullName { get { return Forename + " " + Surname; } }
QUERY WITH ERROR
string[] arrUsers = (from d in db.tblUsers select d.FullName).ToArray();
Upvotes: 1
Views: 1068
Reputation: 22794
You'll have to select it manually:
string[] arrUsers = (from d in db.tblUsers select (d.Forename ?? "") + " " + (d.Surname ?? "")).ToArray();
Upvotes: 3
Reputation: 60493
because it doesn't exist in your db, so linq2entities can't generate proper sql
so
Solution1
concatenate in your query, using a coalesce operator (if you don't and one part is NULL, all will be null).
select d.ForeName ?? string.Empty + " " + d.Surname ?? string.Empty
Solution2
select d.Forename, d.Surname
and you will be able to use FullName
when you'll have enumerated the Queryable
Solution3
Use a computed column
Upvotes: 2