【发布时间】:2013-04-15 06:29:51
【问题描述】:
在 linq 中加入不同的字段类型
public partial class Product
{
public int ID { get; set; }
public string CategoryID
{
get { return Myclass.increse(CategoryID); }
set { CategoryID = value; }
}
public string Name { get; set; }
}
public partial class ProductCategory
{
public int ID { get; set; }
public string Name { get; set; }
}
var query = (from c in dContext.ProductCategories
join p in dContext.Products
on Myclass.EncodeMD5(c.ID.ToString()) equals p.CategoryID
select new { id = p.ID, cat = p.CategoryID, name = p.Name, cat1 = c.Name }
).ToList();
该字段应转换为字符串 然后函数运行EncodeMD5
错误:
LINQ to Entities 无法识别方法 'System.String EncodeMD5(System.String)' 方法,这个方法不能翻译 进入商店表达式。
【问题讨论】:
-
现在有什么问题......?
-
您确定该示例符合该错误消息吗?在该示例中,LINQ 可以看到
EncodeMD5方法和CategoryID属性(我希望它会抱怨这两者),但您没有显示它increse -
已更正 LINQ to Entities 无法识别方法 'System.String EncodeMD5(System.String)' 方法,并且此方法无法转换为存储表达式。
标签: c# linq c#-4.0 entity-framework-4 entity-framework-4.1