Title says it all. I want to be able to work with system stored procedures (sp_helpXXX etc) through generated Linq-To-SQL or Entity Framework wrappers. Problem is, system sprocs are not listed in the generation wizards. I have also tried running sqlmetal.exe manually, but no system stored procedures show up.
views:
413answers:
1
A:
I don't know if there is automatic way, but in linq2sql you can define stored procedures and function by hand on the partial class of the data context.
Here is one I use for the sql's GetDate function (which I can use in the linq query expressions):
[Function(Name = "GetDate", IsComposable = true)]
public DateTime GetSystemDate()
{
MethodInfo mi = MethodBase.GetCurrentMethod() as MethodInfo;
return (DateTime)this.ExecuteMethodCall(this, mi, new object[] { }).ReturnValue;
}
The same principle applies for Stored Procedure (add a regular stored procedure through the designer, and check it out in the generated code).
eglasius
2009-03-27 21:11:30