MVC多层次关系 [英] MVC multi level relationships
本文介绍了MVC多层次关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个如下所示的父子关系:
Groups-> Properties-> SubProperties-> Values。
这是追踪数据的最佳方式。
i知道这是一个解决方案:
I have a parent child relation ship like below :
Groups->Properties->SubProperties->Values.
Which is the best way to follow to retrive the data.
i know this as a solution :
foreach(Group grp in grplist)
{
fetch the properties of(grp);
foreach(property prp in prplist)//loop through the properties list
{
fetch the sub properties of (prp)
foreach(subproperty subprp in subprplist)
{
fetch the values of (subprp)
}
}
}
所有上述foreach意味着一个linq查询
请建议最佳实践。
all the above foreach means a linq query
Please suggest the best practice.
推荐答案
假设您正在使用Entity Framework,解决方案是禁用延迟加载。然后通常在运行查询时使用Include方法。
https://msdn.microsoft.com/en-us/data/jj574232.aspx [ ^ ]
Assuming you are using Entity Framework, the solution is to disable lazy loading. You do then normally by using the Include method when running your query.
https://msdn.microsoft.com/en-us/data/jj574232.aspx[^]
这篇关于MVC多层次关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文