这可能吗?
...
Int32? Id = 1;
QDataContext qDataContext = new QDataContext();
var q= from p in qDataContext.GetProcedurePersonas(Id)
select p.name, p.last;
...
当我运行此命令时,出现错误:
Could not find an implementation of the query pattern for source type 'System.Data.Linq.ISingleResult WcfService1.GetProcedurePersonasResult'.
'Select' not found. Are you missing a reference to 'System.Core.dll' or a using directive for 'System.Linq'?
我也有这个并且工作完美
...
Int32? Id = 1;
QDataContext qDataContext = new QDataContext();
var q= qDataContext.GetProcedurePersonas(Id);
...
最佳答案
如果您已经拥有
QDataContext qDataContext = new QDataContext();
var q= qDataContext.GetProcedurePersonas(Id);
例如,您想从您可能执行的操作中选择特定的内容。
var specific=(from c in q where c.columnvalue == yourValue select c.columnvalue).ToList();
要序列化为 json,您可以使用
JavaScriptSerializer jss = new JavaScriptSerializer();
string json = jss.Serialize(specific);
关于c# - 如何从 SQL to Linq 中的存储过程中进行选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12462564/