Ado.net to Entity Data Model Linq左外连接问题
var v = from u in ucc.uctuserwhere u.jibie <= 2
join c in ucc.provinces on u.jijieno equals c.id into guc
from g in guc.DefaultIfEmpty()
select new { u.id, u.usertuser, u.pwd, u.mobile, u.tel, u.jibie, cityname = (g == null ? "无" : g.provincename) };
foreach(var item in v)
{
System.Diagnostics.Trace.WriteLine(string.Format("username={0},cityname={1}",item.usertuser,item.cityname));
}
foreach求值错误,
用户代码未处理 System.NotSupportedException
Message="LINQ to Entities 不识别方法“System.Collections.Generic.IEnumerable`1[UnCommu.EDM.province] DefaultIfEmpty[province](System.Collections.Generic.IEnumerable`1[UnCommu.EDM.province])”,因此该方法无法转换为存储表达式。"
Source="System.Data.Entity"
StackTrace:
在 System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.DefaultTranslator.Translate(ExpressionConverter parent, MethodCallExpression call)
在 System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq)
在 System.Data.Objects.ELinq.ExpressionConverter.TypedTranslator`1.Translate(ExpressionConverter parent, Expression linq)
在 System.Data.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
在 System.Data.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input)
在 System.Data.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input, DbExpressionBinding& binding)
在 System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.OneLambdaTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, DbExpression& source, DbExpressionBinding& sourceBinding, DbExpression& lambda)
在 System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.OneLambdaTranslator.Translate(ExpressionConverter parent, MethodCallExpression call)
在 System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.SelectManyTranslator.Translate(ExpressionConverter parent, MethodCallExpression call)
在 System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.SequenceMethodTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, SequenceMethod sequenceMethod)
在 System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq)
在 System.Data.Objects.ELinq.ExpressionConverter.TypedTranslator`1.Translate(ExpressionConverter parent, Expression linq)
在 System.Data.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
在 System.Data.Objects.ELinq.ExpressionConverter.Convert()
在 System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption)
在 System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
在 System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
在 UnCommu.View.UserList.Page_Load(Object sender, EventArgs e) 位置 E:\ProjectVS2008\UnCommu\UnCommu\View\UserList.aspx.cs:行号 30
在 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
在 System.Web.UI.Control.OnLoad(EventArgs e)
在 System.Web.UI.Control.LoadRecursive()
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
--------------------编程问答-------------------- up --------------------编程问答-------------------- 看的我眼晕.........UP!! --------------------编程问答-------------------- 眼花了,看不懂了 --------------------编程问答-------------------- 头更晕,跟踪调试信息一大堆,问题却没有说清楚,楼主要怎么能帮你, --------------------编程问答-------------------- 直接跟数据,说出你要的结果吧 --------------------编程问答-------------------- EF好像不支持DefaultIfEmpty。
我也没找到如何查询左连接的方法。
补充:.NET技术 , C#