动态存储过程名称linq to sql

Doo*_*oie 5 linq-to-sql

有没有办法将存储过程名称作为字符串传递给函数然后使用反射来实际获取sp在linq到sql查询中使用?

Mag*_*nus 4

尝试这个

var sp = typeof(DataContext).GetMethod("GetUsersByID"); //Get the SP
var result = sp.Invoke(DbContext, new object[]{100}); //Execute the SP with 100 as the parameter
Run Code Online (Sandbox Code Playgroud)