[英]Returning the value of LINQ Query ASP.NET MVC5
在我的存储库类中,我有这个:
public xxxxx GetByxxxx(string value)
{
return context.xxxxx.Where(r => r.value== value).FirstOrDefault();
}
然后我像这样在我的控制器中调用它
var result = ((xxxxRepo.GetByName(name)));
结果的值不断返回 null,但 name 使用以下方法不断返回 db 上的值:
System.Diagnostics.Debug.WriteLine("The result is " + result);
我错过了什么。
你是返回对象。 所以当你打印值时使用这个。
System.Diagnostics.Debug.WriteLine("The result is " + result==null?"":result.Name);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.