运行查询后出现以下错误:
System.NotSupportedException : The member 'Application.Product.IsValid' has no supported translation to SQL.
以下查询有什么问题?
部分产品类别:
public Boolean IsValid
{
get { return this.isValid; }
set
{
isValid = value;
}
}
我有一个查询如下:
Table<Product> Producttable = dataContext.GetTable<Product>();
Table<ClientProduct> ClientProducttable = dataContext.GetTable<ClientProduct>();
var query =
from product in Producttable where product.IsValid == true
join clientProduct in ClientProducttable
on product.ID equals clientProduct.ProductID
where clientProduct.ClientID == clientID
orderby product.Name ascending
select product;
如果我这样做,我也会得到同样的错误
Table<Product> table = dataContext.GetTable<Product>();
IQueryable<Product> query =
from row in table
where row.IsValid == false
select row;
return query.ToList<Product>();
最佳答案
使用 Column
属性标记您的 Isvalid
属性。
我相信,Linq-to-sql 引擎需要有一个column
属性才能查找数据库表。以及它的(属性的)参数,例如 ColumnName 等。
关于c# - linq 成员不支持 SQL 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19135078/