我试图加入两个表,比较一个int类型的列和一个varchar类型的列,但是没有我尝试的东西我得到一些转换错误...
using (Ginkgo5Entities dataContext = new Ginkgo5Entities())
{
var x = (
from node in dataContext.new_users_teams
join udata in dataContext.new_users_data
on new {
x = SqlFunctions.StringConvert((double)node.ID),
y = "team" }
equals new {
x = udata.value,
y = udata.key }
from parent in dataContext.new_users_teams
where node.lft >= parent.lft && node.lft <= parent.rgt && parent.ID == 6
select new {
team = node.team_name
// udata = udata }
).ToList();
}
抛出
&#34; {指定的方法&#39; System.String StringConvert(System.Nullable`1 [System.Double])&#39;在类型&#39; System.Data.Objects.SqlClient.SqlFunctions&#39;无法转换为LINQ to Entities商店表达式。}&#34;
问题:
非常感谢!
答案 0 :(得分:2)
尝试将此查询更改为:
var x = (from node in dataContext.new_users_teams
join udata in dataContext.new_users_data on node.ID equals udata.value.ToString() and udata.key equals "team" }
from parent in dataContext.new_users_teams
where node.lft >= parent.lft && node.lft <= parent.rgt && parent.ID == 6