在尝试连接Oracle中的两个表时,我遇到了以下问题 . 其中一个表有一个字符串值,另一个表是long .
var query = (from d in context.entity
join m in context.entity2
on d.ordernum.Substring(2) equals m.ordernum.ToString())
select new { d.ordernum, d.customer, m.recordkey});
var items = query.ToList();
问题是这不适用于Oracle
-
不能使用SQLFunctions,因为这是一个Oracle数据库
-
不能使用.ToString()
LINQ to Entities无法识别方法'System.String ToString()'方法,并且此方法无法转换为存储表达式 .
- 强制使用long.Parse()
LINQ to Entities无法识别方法'Int64 Parse(System.String)'方法,并且此方法无法转换为存储表达式 .
任何帮助将不胜感激 .
1 回答
您可以使用AsEnumerable(),因此它将在C#中运行,并且不会获得这些错误 .
否则你可以扩展它和write your "own" functions . 像:(未经测试)