Entity Framework does not support Custom Properties in Queries

As I am starting to learn more and more, I think linq to sql first release is much more mature that v1 release of entity framework. For instance, in linq to sql, if I would create custom property in my partial class, I could actually use that custom property in the projection of my query. One of the obvious reasons for creating custom property is to reuse code functionality such as creating a property called Name which combines, FirstName and LastName. You really don't to write that code all over you class diagram. Exposing the function as a property and being able to use that property in a projection is a valuable functionality added to the framework. Below is the code that shows using custom property in a projection of a query.

image

In the above example, I am using the custom property Name available on Employee partial class to project the output in an anonymous type.

Something like, is currently not supported by entity framework. When I run code similar to to above in entity framework, I get the following exception.

image

image

In the above code, I am making use of custom property Name with entity framework and I am greeted with an exception stating that Name being a custom property is not supported.

No Comments