views:

25

answers:

1

Hi,

I am using EF4 and I am getting an error with my custom property. I have 2 properties in my Application class, namely Initials and Surname. It is a partial class. I created a custom property in my Application class called Owner, and it looks like this:

public partial class Application
{
   public string Owner
   {
      get
      {
         return Initials + " " + Surname;
      }
   }
}

When I add it to my grid like this:

m => m.Owner

Then I get the following error:

The specified type member 'Owner' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.

How do I fix this?

Thanks Brendan

+1  A: 

I think you should show more code because at the moment description of your problem is not complete. Anyway you can't use Owner property in any Linq query working with IQueryable (Linq to entities). Custom properties can never appear in Linq to entities query because such query is mapped to SQL where the property doesn't exist. You first have to select data with Linq to entities, call ToList or AsEnumerable and than select properties including Owner in Linq to objects.

Ladislav Mrnka