How do I get the schema of a stored procedure using Linq to SQL?
2 answers
During development? Just drag the stored procedure onto the LINQ designer surface.
At run time?
You need sql like this:
SELECT *
FROM syscolumns
WHERE id =
(
SELECT id
FROM sysobjects
WHERE Name = @ProcName
)
Which can be called by LinqToSql like this:
var params =
db.sysobjects
.Where(o => o.Name == ProcName)
.SelectMany(o =>
db.syscolumns
.Where(c => c.id == o.id)
)
+2
source to share