LINQ to SQL > Stored Procedures > IQueryable return type?
-
Wednesday, December 26, 2007 1:28 AMI'm using Visual Studio 2008 RTM.
Problem:
When i'm drag'n'drop a stored procedure into the dbml designer, it generates a method with a generic ISingleResult<SomeClass> type:
[Function(Name="dbo.SearchForSomething")]
public ISingleResult<SomeClass> SearchForSomething([Parameter(DbType="NVarChar(MAX)")] string search)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), search);
return ((ISingleResult<SomeClass>)(result.ReturnValue));
}
I want to use this stored procedure in advanced LINQ query, efficiently. I could write my own implementation of the generated method with a generic IQueryable<SomeClass> return type, but i'd prefer a setting in the designer, that tells the codegenerator 'make a method with IQueryable return type'. Does this setting exists or i sould write these methods by 'hand'?
All Replies
-
Wednesday, December 26, 2007 1:17 PM
Hi Andras,
Sprocs cannot return an object of type IQueryable (unless you do some custom code under the covers). The best approach to take it to use 'Table Functions', then when you add them to your data context, they can return IQueryable...
Hope this helps and make sense. If you need anything else please say.
Thanks
Ben
-
Wednesday, December 26, 2007 6:34 PMyes, that makes sense, thx
after i wrote my question, i found this page:
http://geeks.netindonesia.net/blogs/kasim.wirama/archive/2007/11/29/execute-stored-procedure-and-function-from-linq.aspx
it says what you said.

