S'Ok. this is what I ended up doing.
Using POCO's
Ie. the .edmx
, Custom Tool
is removed / no auto-generated entities, etc.
- Import Function :: manually import the stored procedure.
In your context class ...
public class SqlServerContext : ObjectContext, IUnitOfWork
{
public SqlServerContext(EntityConnection entityConnection,
ILoggingService loggingService)
: base(entityConnection) { .... }
public ObjectResult<Location> FindLocationsWithinABoundingBox(decimal upperLeftLongitude,
decimal upperLeftLatitude,
decimal lowerRightLongitude,
decimal lowerRightLatitude)
{
return base.ExecuteFunction<Location>("FindLocationsWithinABoundingBox",
new ObjectParameter("UpperLeftLatitude", upperLeftLongitude),
new ObjectParameter("UpperLeftLongitude", upperLeftLatitude),
new ObjectParameter("LowerRightLongitude", lowerRightLongitude),
new ObjectParameter("LowerRightLatitude", lowerRightLatitude));
}
}
Using the Auto-Generated Entities, etc. (The default way EF is setup)
- Create a custom COMPLEX TYPE (which will be used to map the stored procedure, too).
- Import Function :: manually import the stored procedure.
- Map the RETURN TYPE (of the imported sp) to the custom COMPLEX TYPE you've made.
dat's it.
Not sure if my POCO way is the best way to do things, but it .. well .. works :)
And this is a related StackOverflow question I asked about using this stored procedure in a services / IQueryable way ... :)