Welcome to MSDN Blogs Sign in | Join | Help
All the power at your disposal

I invite you to take a look at this forum post from 'Benys'

It illustrates the power of the Entity Framework's mapping capabilities + partial classes.

The short answer to a lot of "Does the EF support ... ?" type questions is often no. 

Often however the longer answer, is a little easier to digest.

If you start using the power of DefiningQueries / Partial Classes / View / Stored Procs suddenly lots of things become possible.

The nice thing about 'Benys' example is that while UDTs ( spatial types are basically UDTs ) are not natively supported by the Entity Framework, there is a nice work around...

Here is the pattern:

  1. Define your Entity with Binary properties rather than UDT properties
  2. Create a DefiningQuery in your SSDL that uses T-SQL to convert from the UDT to binary.
  3. In the partial class add a property that goes from binary back to you UDT in memory.

The are a few caveats of course*, but this is just the sort of work-around that allows you to handle an issue that might otherwise be a real show-stopper.

* Issues (non exhaustive list)

  • The property you define in your partial class can't be used in a query
  • You can't make use of a UDT's operations in a query
  • The extra step of materializing twice (the Binary + the UDT) makes it a little slower
  • You have to keep your partial class properties and the entity properties in sync
Posted: Monday, February 25, 2008 8:09 PM by AlexJ
Filed under: , , , ,

Comments

Matthieu MEZIL said:

Dans un précédent post , j'avais signalé, via la réponse de Daniel Simmons , que les UDT n'étaient pas

# February 26, 2008 5:30 AM

benys said:

Also if you want to modify objects, you have to define insert/update/delete store procedures for type and some navigation properties :(

# March 2, 2008 3:19 PM

Eric and the .NET Framework said:

This one has come up a few times. LINQ to SQL and LINQ to Entities in V1 do not currently support the

# October 15, 2008 4:49 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker