/// <summary> /// Loads the UserRole entities associated to the instances (entity.UserRole collection property). /// </summary> /// /// <param name="entities"> /// The target entity collection. /// </param> public void LoadUserRoleCollection(TCollection <VahapYigit.Test.Models.Role> entities) { if (entities != null) { var collection = entities.Where(i => i.IsInDb).ToTCollection(); var idList = collection.Select(i => i.Id).ToList(); var options = new SearchOptions(); options.Filters.Add(VahapYigit.Test.Models.UserRole.ColumnNames.IdRole, FilterOperator.In, idList); using (var db = new UserRoleCrud(base.UserContext)) { var data = db.Search(ref options); foreach (var entity in collection) { entity.UserRoleCollection = data.Where(i => i.IdRole == entity.Id).ToTCollection(); } foreach (var item in data) { item.Role = collection.First(i => i.Id == item.IdRole); } } } }
/// <summary> /// Loads the UserRole entities associated to the current instance (entity.UserRole collection property). /// </summary> /// /// <param name="entity"> /// The target entity. /// </param> public void LoadUserRoleCollection(ref VahapYigit.Test.Models.Role entity) { if (entity != null && entity.IsInDb) { var options = new SearchOptions(); options.Filters.Add(VahapYigit.Test.Models.UserRole.ColumnNames.IdRole, FilterOperator.Equals, entity.Id); using (var db = new UserRoleCrud(base.UserContext)) { entity.UserRoleCollection = db.Search(ref options); } foreach (var item in entity.UserRoleCollection) { item.Role = entity; } } }