static Site GetSite(string id) { SiteMeta siteMeta = null; using (var readContext = new SiteDbContext()) { siteMeta = readContext.Sites.FirstOrDefault(s => s.Id == id); } return(new Site { Info = siteMeta }); }
static List <Site> GetSites(ResolveFieldContext <object> context) { List <SiteMeta> siteMetas = new List <SiteMeta>(); List <Site> sites = new List <Site>(); using (var readContext = new SiteDbContext()) { siteMetas = readContext.Sites.Take(50) .OrderByDescending(site => site.Name) .ToList(); } foreach (var siteMeta in siteMetas) { sites.Add(new Site { Info = siteMeta }); } return(sites); }