ChanikyaGuptha

ChanikyaGuptha

  • NA
  • 148
  • 1.1k

How do I get the huge data from web.api?

Aug 21 2018 11:50 PM
Hi, I'm new to web.api. I've two cases both will results the same.
 
Case: 1 Getting the result in single LINQ.
Case: 2 First get the all the data from each table and executing LINQ.
 
   Which is the best way to get the very huge data fastly? I've data like POSTS, Comments and replies just like facebook.
 
   And as i heard that for huge data we need to have pagination. If <b>YES</b> please guide me regarding that.
 
   And these are the code ive.
 
Case1:
 
      var query = (from p in db.TblPost where (from q in db.TblThread where q.LocationLocationid == locationID && q.CategoriesCategoryid == categoryID select q.Threadid).Contains(p.ThreadThreadid) join r in db.TblThread on p.ThreadThreadid equals r.Threadid join s in db.TblUser on p.UserUserid equals s.Userid join t in db.TblCategories on r.CategoriesCategoryid equals t.Categoryid join u in db.TblLocation on r.LocationLocationid equals u.Locationid orderby r.CreatedTime descending select new { p, r.Subject, r.EventAddress, r.EventClosetime, r.EventDate, r.EventDuration, r.EventStarttime, r.EventTitle, r.IseventAllday, r.TargetUsers, r.CreatedTime, s.FirstName, s.MiddleName, s.LastName, t.Name, u.Locationname, r.Isreadonly }).ToList();
 
 
Case 2:
 
         List<TblPost> _tblPost = new List<TblPost>();
         _tblPost = (from p in db.TblPost select p).ToList();
 
         List<TblThread> _tblThread = new List<TblThread>();
         _tblThread = (from p in db.TblThread select p).ToList();
 
         List<TblUser> _tblUser = new List<TblUser>();
         _tblUser = (from p in db.TblUser select p).ToList();
 
         List<TblLocation> _tblLocation = new List<TblLocation>();
         _tblLocation = (from p in db.TblLocation select p).ToList();
 
         List<TblCategories> _tblCategory = new List<TblCategories>();
         _tblCategory = (from p in db.TblCategories select p).ToList();
 
 
   var query = (from p in _tblPost where (from q in _tblThread where q.LocationLocationid == locationID && q.CategoriesCategoryid == categoryID select q.Threadid).Contains(p.ThreadThreadid) join r in _tblThread on p.ThreadThreadid equals r.Threadid join s in _tblUser on p.UserUserid equals s.Userid join t in _tblCategory on r.CategoriesCategoryid equals t.Categoryid join u in _tblLocation on r.LocationLocationid equals u.Locationid orderby r.CreatedTime descending select new { p, r.Subject, r.EventAddress, r.EventClosetime, r.EventDate, r.EventDuration, r.EventStarttime, r.EventTitle, r.IseventAllday, r.TargetUsers, r.CreatedTime, s.FirstName, s.MiddleName, s.LastName, t.Name, u.Locationname, r.Isreadonly }).ToList();
 
 
      I've these tow codes which results the same. But, in `case 2` i'm getting the result some quickly as compared to `case 1`. Which one should i need to follow?
 

Answers (1)