public ICollection <BranchlistVM> GetAllBrancheswithOrganizationName() { var joinlist = from bra in Context.Branch join org in Context.Organization on bra.OrganizationId equals org.Id select new { branchid = bra.Id, branchname = bra.Name, branchshortname = bra.ShortName, locationname = bra.LocationName, organizatrionname = org.Name, organizationid = org.Id, }; ICollection <BranchlistVM> list = new List <BranchlistVM>(); foreach (var t in joinlist) { BranchlistVM branches = new BranchlistVM(); branches.Id = t.branchid; branches.Name = t.branchname; branches.ShortName = t.branchshortname; branches.OrganizationId = t.organizationid; branches.Organization = t.organizatrionname; branches.LocationName = t.locationname; list.Add(branches); } return(list.ToList()); }
public ICollection <BranchlistVM> GetSome(int n) { var join = from bra in Context.Branch join org in Context.Organization on bra.OrganizationId equals org.Id select new { branchname = bra.Name, branchshortname = bra.ShortName, location = bra.LocationName, organizatrionname = org.Name, branchid = bra.Id, organizationid = org.Id }; var joinlist = join.Take(n).OrderByDescending(c => c.branchid).ToList(); ICollection <BranchlistVM> list = new List <BranchlistVM>(); foreach (var t in joinlist) { BranchlistVM branches = new BranchlistVM(); branches.Name = t.branchname; branches.ShortName = t.branchshortname; branches.Organization = t.organizatrionname; branches.LocationName = t.location; branches.OrganizationId = t.organizationid; list.Add(branches); } return(list.ToList()); }