[OperationContract]
public List<Drug> GetAll_Drug()
{
List<Drug> obj_Lst_t;
using (var ctx = new EpriscriptionContext())
{
obj_Lst_t = ctx.Drug.ToList();
}
return obj_Lst_t;
}
得到答案 ------但添加OperationContract get error
调试 获取返回数据错误
答案 0 :(得分:0)
根据您的堆栈跟踪屏幕
System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException
所以我认为这可能是由于延迟加载或EF代理序列化造成的。
尝试停用代理。
[OperationContract]
public List<Drug> GetAll_Drug()
{
List<Drug> obj_Lst_t;
using (var ctx = new EpriscriptionContext())
{
ctx.Configuration.ProxyCreationEnabled = false; // disable proxy creation here.
obj_Lst_t = ctx.Drug.ToList();
}
return obj_Lst_t;
}
答案 1 :(得分:0)
当返回Data ctx dispose时, 然后obj_Lst_t值转换为null, 或使用:
explain.n
或使用:
[OperationContract]
public List<Drug> GetAll_Drug()
{
List<Drug> obj_Lst_t;
using (var ctx = new EpriscriptionContext())
{
ctx.Configuration.ProxyCreationEnabled = false;
foreach(var data in ctx.Drug)
{ obj_Lst_t.add(data);}
}
return obj_Lst_t;
}
答案 2 :(得分:0)
添加以下代码错误
[OperationContract]
public List<Patients> GetAll_Patients()
{
List<Patients> obj_Lst_t;
using (var ctx = new EpriscriptionContext())
{
ctx.Configuration.ProxyCreationEnabled = false;
obj_Lst_t = ctx.Patients.ToList();
}
return obj_Lst_t;
}
答案 3 :(得分:-1)
Yoe moust删除使用,
[OperationContract]
public List<Drug> GetAll_Drug()
{
List<Drug> obj_Lst_t;
var ctx = new EpriscriptionContext();
ctx.Configuration.ProxyCreationEnabled = false;
obj_Lst_t = ctx.Drug.ToList();
}