Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling SQL Server function without EDMX
Message
De
30/12/2014 14:30:55
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Entity Framework
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01612850
Message ID:
01612860
Vues:
54
This message has been marked as a message which has helped to the initial question of the thread.
>I'd like to call the function directly but apparently it's not possible. I think we're using EF6. I'm looking right now into SqlQuery method explained here http://msdn.microsoft.com/en-us/data/jj592907.
>
>>Depending on the version of EF, you can call a stored proc, which can call the function.
>>
>>
>>
>>
>>>Hi everybody,
>>>
>>>I'm wondering if there is a way to use SQL Server function (in particular, we have function that calculates age based on the birthday) without using EDMX?
>>>
>>>I checked this link http://msdn.microsoft.com/en-us/library/vstudio/dd456847(v=vs.100).aspx but wondering if there is any other way.
>>>
>>>This is what I started to write:
>>>
>>>
>>>  var query = db.Guests.Select(g => new GuestsList
>>>            {
>>>                LastName = g.LastName,
>>>                FirstName = g.FirstName,
>>>                BirthDate = g.BirthDate,
>>>                Phone = g.Address.AreaCode.Trim() + g.Address.Phone.Trim()
>>>               
>>>            });
>>>
>>>We have a SQL Server function dbo.siriusfn_AgeToday(g.birth_date) which I'd like to include into this query.
>>>
>>>Thanks a lot in advance.
>>>
>>>UPDATE. Looks like it's not supported in Code First :( http://data.uservoice.com/forums/72025-entity-framework-feature-suggestions/suggestions/1953237-code-first-support-for-user-defined-functions-udf
>>>
>>>I added 3 votes.

I haven't used it myself, but this post indicates support for UDFs was added to Code First in 6.1.1: http://blog.3d-logic.com/2014/08/11/the-beta-version-of-store-functions-for-entityframework-6-1-1-code-first-available/. The article is discussing the beta version though, so its possible that it was removed in the RTM version.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform