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 YES 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 = new List();
_tblPost = (from p in db.TblPost select p).ToList();
List _tblThread = new List();
_tblThread = (from p in db.TblThread select p).ToList();
List _tblUser = new List();
_tblUser = (from p in db.TblUser select p).ToList();
List _tblLocation = new List();
_tblLocation = (from p in db.TblLocation select p).ToList();
List _tblCategory = new List();
_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?
Gautam ParmarPosted Aug 22, 2018, 6:24 AM