public void MT_Serialization_EagerLoadOptions() { var elo = new EagerLoadOptions(); elo.LoadWith(Book.ChapterListProperty); elo.LoadWith(Chapter.SectionListProperty); elo.LoadWith(Section.SectionOwnerProperty); var elo2 = ObjectCloner.Clone(elo); Assert.AreEqual(elo.CoreList.Count, 3); Assert.AreEqual(elo.CoreList[0].Property, Book.ChapterListProperty); Assert.AreEqual(elo.CoreList[1].Property, Chapter.SectionListProperty); Assert.AreEqual(elo.CoreList[2].Property, Section.SectionOwnerProperty); }
public virtual RoleOperationList GetByRoleId(long id) { EagerLoadOptions eagerload = new EagerLoadOptions(); eagerload.LoadWith(RoleOperation.OperationProperty).LoadWith(ResourceOperation.ResourceProperty); var q = this.CreateLinqQuery(); q = q.Where(e => e.RoleId == id); return((RoleOperationList)this.QueryData(q, null, eagerload)); }
/// <summary> /// 贪婪加载聚合子实体 /// </summary> /// <param name="eagerLoadOptions"></param> /// <param name="entityMeta"></param> /// private static void EagerLoadAggregationRecur(EagerLoadOptions eagerLoadOptions, EntityMeta entityMeta) { var childProperties = entityMeta.ChildrenProperties; if (childProperties.Count > 0) { foreach (var childPropertyMeta in childProperties) { var listProperty = childPropertyMeta.ManagedProperty as IListProperty; if (listProperty != null) { eagerLoadOptions.LoadWith(listProperty); } EagerLoadAggregationRecur(eagerLoadOptions, childPropertyMeta.ChildType); } } }
/// <summary> /// 贪婪加载聚合子实体 /// </summary> /// <param name="isHasChild"></param> /// <param name="entityMeta"></param> /// <param name="eagerLoadOptions"></param> private static void LoadChildListProperty(ref bool isHasChild, EntityMeta entityMeta, EagerLoadOptions eagerLoadOptions) { var childProperties = entityMeta.ChildrenProperties; if (childProperties != null && childProperties.Count > 0) { foreach (var childPropertyMeta in childProperties) { var listProperty = childPropertyMeta.ManagedProperty as IListProperty; if (listProperty != null) { if (!isHasChild) { isHasChild = true; } eagerLoadOptions.LoadWith(listProperty); } LoadChildListProperty(ref isHasChild, childPropertyMeta.ChildType, eagerLoadOptions); } } }