views:

525

answers:

2

I'm new with the Entity Fw.

I have a Sql Function that returns the age for a given birthday. (http://www.sql-server-helper.com/functions/get-age.aspx)

And I whant to use it with linq. I know it's possible. I've read it here: http://blogs.msdn.com/efdesign/archive/2009/01/07/model-defined-functions.aspx http://blogs.msdn.com/efdesign/archive/2008/10/08/edm-and-store-functions-exposed-in-linq.aspx

but it seems this is part of the EF extentions (which I have) or that is still on development fase.

Can anyone help me with this?

Thank you.

+1  A: 

You might be able to do a "FunctionImportMapping" see msdn for more info.. You could definitley do it that way if you exposed it as a sproc, I've not tried with just a function tho..

DeletedAccount
+1  A: 

Model defined functions are not in the shipping Entity Framework, and I don't think they are in the extensions, either. As far as I know, they are a new feature planned for .NET 4.0. I don't know if they are in the Community Technology Preview of that. You can see a demo of model defined functions if you watch the Entity Framework presentation from PDC. But they are certainly not in .NET 3.5 SP1.

As a workaround, you could define a computed column on your table which used the function and then map that column instead of mapping the function directly.

Craig Stuntz