/// <summary> /// Gets the region by it's internal id. Note that this method is dependent on /// that the RegionTemplate entity is included with the region. /// </summary> /// <param name="regions">The region list</param> /// <param name="internalId">The internal id</param> /// <returns>The region</returns> public static Region ByInternalId(this IList<Region> regions, string internalId) { using (var db = new Piranha.DataContext()) { foreach (var reg in regions) { if (reg.RegionTemplate == null) reg.RegionTemplate = db.RegionTemplates.Where(t => t.Id == reg.RegionTemplateId).Single() ; } } return regions.Where(r => r.RegionTemplate.InternalId == internalId).SingleOrDefault() ; }