设置LazyLoadingEnabled EF 4.X POCO Entity Generator for C#
「已注销」 2012-04-18 01:44:56 小弟用EF 4.x POCO Entity Generator for C# 生成entity class(一个数据的表对应一个class)
LazyLoadingEnabled默认是true,我看到他人的code是设置成false.
using (wimEntities context = new wimEntities(m_connectionString))
{
// You can disable the proxy creation
// by setting context.ContextOptions.ProxyCreationEnabled to false
context.ContextOptions.LazyLoadingEnabled = false;
// The order was created as a POCO proxy object.
// But it will be recieved on the client as a pure POCO.
WimDataEntity.user oUser = context.users.SingleOrDefault(u => u.userid == userId && u.deleted == false);
return oUser;
}
我想知道这里设置成false有必要吗? 或者上面这个例子设置成false有必要吗?
像下面这个例子 设置成false还是true好能?
using (wimEntities context = new wimEntities(m_connectionString))
{
var result = from uw in context.userworkflows
join wf in context.workflows on uw.wfid equals wf.workflowid
join wq in context.workflowquestions on wf.workflowid equals wq.workflowid
where uw.userworkflowid == userWorkflowId && wq.questionname == queestionName
orderby wq.questionorder
select wq;
WimDataEntity.workflowquestion oWQ = null;
foreach (WimDataEntity.workflowquestion oworkflowQusetion in result)
{
oWQ = oworkflowQusetion;
break;
}
return oWQ;
}
还需要设置context.ContextOptions.ProxyCreationEnabled吗?
认真回答 可以另开帖送分 分不是问题