public virtual Biota GetBiota(ShardDbContext context, uint id, bool doNotAddToCache = false) { var biota = context.Biota .FirstOrDefault(r => r.Id == id); if (biota == null) { return(null); } PopulatedCollectionFlags populatedCollectionFlags = (PopulatedCollectionFlags)biota.PopulatedCollectionFlags; // todo: There are gains to be had here if we can conditionally perform mulitple .Include (.Where) statements in a single query. // todo: Until I figure out how to do that, this is still pretty good. Mag-nus 2018-08-10 if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesAnimPart)) { biota.BiotaPropertiesAnimPart = context.BiotaPropertiesAnimPart.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesAttribute)) { biota.BiotaPropertiesAttribute = context.BiotaPropertiesAttribute.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesAttribute2nd)) { biota.BiotaPropertiesAttribute2nd = context.BiotaPropertiesAttribute2nd.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesBodyPart)) { biota.BiotaPropertiesBodyPart = context.BiotaPropertiesBodyPart.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesBook)) { biota.BiotaPropertiesBook = context.BiotaPropertiesBook.FirstOrDefault(r => r.ObjectId == biota.Id); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesBookPageData)) { biota.BiotaPropertiesBookPageData = context.BiotaPropertiesBookPageData.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesBool)) { biota.BiotaPropertiesBool = context.BiotaPropertiesBool.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesCreateList)) { biota.BiotaPropertiesCreateList = context.BiotaPropertiesCreateList.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesDID)) { biota.BiotaPropertiesDID = context.BiotaPropertiesDID.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesEmote)) { biota.BiotaPropertiesEmote = context.BiotaPropertiesEmote.Include(r => r.BiotaPropertiesEmoteAction).Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesEnchantmentRegistry)) { biota.BiotaPropertiesEnchantmentRegistry = context.BiotaPropertiesEnchantmentRegistry.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesEventFilter)) { biota.BiotaPropertiesEventFilter = context.BiotaPropertiesEventFilter.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesFloat)) { biota.BiotaPropertiesFloat = context.BiotaPropertiesFloat.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesGenerator)) { biota.BiotaPropertiesGenerator = context.BiotaPropertiesGenerator.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesIID)) { biota.BiotaPropertiesIID = context.BiotaPropertiesIID.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesInt)) { biota.BiotaPropertiesInt = context.BiotaPropertiesInt.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesInt64)) { biota.BiotaPropertiesInt64 = context.BiotaPropertiesInt64.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesPalette)) { biota.BiotaPropertiesPalette = context.BiotaPropertiesPalette.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesPosition)) { biota.BiotaPropertiesPosition = context.BiotaPropertiesPosition.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesSkill)) { biota.BiotaPropertiesSkill = context.BiotaPropertiesSkill.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesSpellBook)) { biota.BiotaPropertiesSpellBook = context.BiotaPropertiesSpellBook.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesString)) { biota.BiotaPropertiesString = context.BiotaPropertiesString.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesTextureMap)) { biota.BiotaPropertiesTextureMap = context.BiotaPropertiesTextureMap.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.HousePermission)) { biota.HousePermission = context.HousePermission.Where(r => r.HouseId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesAllegiance)) { biota.BiotaPropertiesAllegiance = context.BiotaPropertiesAllegiance.Where(r => r.AllegianceId == biota.Id).ToList(); } return(biota); }
protected static void SetBiotaPopulatedCollections(Biota biota) { PopulatedCollectionFlags populatedCollectionFlags = 0; if (biota.BiotaPropertiesAnimPart != null && biota.BiotaPropertiesAnimPart.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesAnimPart; } if (biota.BiotaPropertiesAttribute != null && biota.BiotaPropertiesAttribute.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesAttribute; } if (biota.BiotaPropertiesAttribute2nd != null && biota.BiotaPropertiesAttribute2nd.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesAttribute2nd; } if (biota.BiotaPropertiesBodyPart != null && biota.BiotaPropertiesBodyPart.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesBodyPart; } if (biota.BiotaPropertiesBook != null) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesBook; } if (biota.BiotaPropertiesBookPageData != null && biota.BiotaPropertiesBookPageData.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesBookPageData; } if (biota.BiotaPropertiesBool != null && biota.BiotaPropertiesBool.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesBool; } if (biota.BiotaPropertiesCreateList != null && biota.BiotaPropertiesCreateList.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesCreateList; } if (biota.BiotaPropertiesDID != null && biota.BiotaPropertiesDID.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesDID; } if (biota.BiotaPropertiesEmote != null && biota.BiotaPropertiesEmote.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesEmote; } if (biota.BiotaPropertiesEnchantmentRegistry != null && biota.BiotaPropertiesEnchantmentRegistry.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesEnchantmentRegistry; } if (biota.BiotaPropertiesEventFilter != null && biota.BiotaPropertiesEventFilter.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesEventFilter; } if (biota.BiotaPropertiesFloat != null && biota.BiotaPropertiesFloat.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesFloat; } if (biota.BiotaPropertiesGenerator != null && biota.BiotaPropertiesGenerator.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesGenerator; } if (biota.BiotaPropertiesIID != null && biota.BiotaPropertiesIID.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesIID; } if (biota.BiotaPropertiesInt != null && biota.BiotaPropertiesInt.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesInt; } if (biota.BiotaPropertiesInt64 != null && biota.BiotaPropertiesInt64.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesInt64; } if (biota.BiotaPropertiesPalette != null && biota.BiotaPropertiesPalette.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesPalette; } if (biota.BiotaPropertiesPosition != null && biota.BiotaPropertiesPosition.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesPosition; } if (biota.BiotaPropertiesSkill != null && biota.BiotaPropertiesSkill.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesSkill; } if (biota.BiotaPropertiesSpellBook != null && biota.BiotaPropertiesSpellBook.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesSpellBook; } if (biota.BiotaPropertiesString != null && biota.BiotaPropertiesString.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesString; } if (biota.BiotaPropertiesTextureMap != null && biota.BiotaPropertiesTextureMap.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesTextureMap; } if (biota.HousePermission != null && biota.HousePermission.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.HousePermission; } if (biota.BiotaPropertiesAllegiance != null && biota.BiotaPropertiesAllegiance.Count > 0) { populatedCollectionFlags |= PopulatedCollectionFlags.BiotaPropertiesAllegiance; } biota.PopulatedCollectionFlags = (uint)populatedCollectionFlags; }
public virtual Biota GetBiota(ShardDbContext context, uint id, bool doNotAddToCache = false) { var biota = context.Biota .FirstOrDefault(r => r.Id == id); if (biota == null) { return(null); } PopulatedCollectionFlags populatedCollectionFlags = (PopulatedCollectionFlags)biota.PopulatedCollectionFlags; if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesAnimPart)) { biota.BiotaPropertiesAnimPart = context.BiotaPropertiesAnimPart.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesAttribute)) { biota.BiotaPropertiesAttribute = context.BiotaPropertiesAttribute.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesAttribute2nd)) { biota.BiotaPropertiesAttribute2nd = context.BiotaPropertiesAttribute2nd.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesBodyPart)) { biota.BiotaPropertiesBodyPart = context.BiotaPropertiesBodyPart.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesBook)) { biota.BiotaPropertiesBook = context.BiotaPropertiesBook.FirstOrDefault(r => r.ObjectId == biota.Id); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesBookPageData)) { biota.BiotaPropertiesBookPageData = context.BiotaPropertiesBookPageData.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesBool)) { biota.BiotaPropertiesBool = context.BiotaPropertiesBool.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesCreateList)) { biota.BiotaPropertiesCreateList = context.BiotaPropertiesCreateList.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesDID)) { biota.BiotaPropertiesDID = context.BiotaPropertiesDID.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesEmote)) { biota.BiotaPropertiesEmote = context.BiotaPropertiesEmote.Include(r => r.BiotaPropertiesEmoteAction).Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesEnchantmentRegistry)) { biota.BiotaPropertiesEnchantmentRegistry = context.BiotaPropertiesEnchantmentRegistry.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesEventFilter)) { biota.BiotaPropertiesEventFilter = context.BiotaPropertiesEventFilter.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesFloat)) { biota.BiotaPropertiesFloat = context.BiotaPropertiesFloat.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesGenerator)) { biota.BiotaPropertiesGenerator = context.BiotaPropertiesGenerator.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesIID)) { biota.BiotaPropertiesIID = context.BiotaPropertiesIID.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesInt)) { biota.BiotaPropertiesInt = context.BiotaPropertiesInt.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesInt64)) { biota.BiotaPropertiesInt64 = context.BiotaPropertiesInt64.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesPalette)) { biota.BiotaPropertiesPalette = context.BiotaPropertiesPalette.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesPosition)) { biota.BiotaPropertiesPosition = context.BiotaPropertiesPosition.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesSkill)) { biota.BiotaPropertiesSkill = context.BiotaPropertiesSkill.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesSpellBook)) { biota.BiotaPropertiesSpellBook = context.BiotaPropertiesSpellBook.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesString)) { biota.BiotaPropertiesString = context.BiotaPropertiesString.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesTextureMap)) { biota.BiotaPropertiesTextureMap = context.BiotaPropertiesTextureMap.Where(r => r.ObjectId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.HousePermission)) { biota.HousePermission = context.HousePermission.Where(r => r.HouseId == biota.Id).ToList(); } if (populatedCollectionFlags.HasFlag(PopulatedCollectionFlags.BiotaPropertiesAllegiance)) { biota.BiotaPropertiesAllegiance = context.BiotaPropertiesAllegiance.Where(r => r.AllegianceId == biota.Id).ToList(); } return(biota); }