【问题标题】:Linq to entities multiple WHERE clause &&Linq 到实体多个 WHERE 子句 &&
【发布时间】:2010-02-22 15:22:40
【问题描述】:

在代码中 bdehind && 语法不起作用,有什么想法吗?

Entities ctx3 = new Entities();
var uniqueQuote = from quot in ctx3.Quotes.Include("aspnet_Users").Include("Enquiries")
  where quot.Enquiries.EnquiryId == selectedEnquiryId &&
     quot.aspnet_Users.UserId == currentUserId
  orderby quot.QuotePrice
  select quot;

错误 2 委托“System.Func”不采用“1”参数 C:\LocalGarageFinder\LocalGarageFinder\EnquiryDetail.aspx.cs 56 33 LocalGarageFinder

【问题讨论】:

  • Delegate 'System.Func' 不采用“1”参数 C:\LocalGarageFinder\LocalGarageFinder\EnquiryDetail.aspx.cs 56 33 LocalGarageFinder
  • 无法将 lambda 表达式转换为类型“字符串”,因为它不是委托类型 C:\LocalGarageFinder\LocalGarageFinder\EnquiryDetail.aspx.cs 56 33 LocalGarageFinder
  • 解决了,只需要实例化currentUserId
  • 您可以为其他有相同问题的人发布正确的语法。 Tks

标签: asp.net linq entity-framework linq-to-entities


【解决方案1】:

编写的代码很好。如果您收到某种错误,请告诉我们。

【讨论】:

    【解决方案2】:

    如果 EnquiryId 或 UserId 是 Nullable 类型,您将收到错误消息。使用 EnquiryId.Value == selectedEnquiryId 或 UserId.Value == currentUserId

    【讨论】:

      猜你喜欢
      • 2014-12-08
      • 2012-01-05
      • 2010-10-10
      • 1970-01-01
      • 1970-01-01
      • 2015-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多