Hi Starlene,
Nice coding and you are maintaining good coding patteren and here is the solution i am expecting from your problem.
in the query you taken first 'Take()' function and then you taken the 'Skip()' function, the order you followed for Take and Skip is only wrong in your code so please chcek the code as first write skip and then go for Take function.
Yours original code:
var query = from p in dc.links
.Take(take)
.Skip(pageSize)
orderby p.SubmittedDate descending
where p.Status =="Approved"
select new
{
p.Link_ID ,
title = p.Title,
url = p.Url,
keyword = p.Keyword,
description = p.Descriptions,
email = p.Email,
contactname = p.ContactName,
p.SubmittedDate,
Count = dc.Backlinks.Count()
};
Corrected code :
var query = from p in dc.links
.Skip(pageSize)
.Take(take)
orderby p.SubmittedDate descending
where p.Status =="Approved"
select new
{
p.Link_ID ,
title = p.Title,
url = p.Url,
keyword = p.Keyword,
description = p.Descriptions,
email = p.Email,
contactname = p.ContactName,
p.SubmittedDate,
Count = dc.Backlinks.Count()
};
Description for Skip and Take function is as follows
Skip:-Bypasses a specified number of elements in a sequence and then returns the remaining elements.
Take:- Returns a specified number of contiguous elements from the start of a sequence.
when you are using first it takes n number of records first and then skip By passes n no of records then we cann't find no record in the resultant 'query' then you are requesting count form this, so it is throwing an error message.
RowCount = query.First().Count;
"We can't get any thing from nothing"
if the above solution is not works please reply to this post with you new problem or error
Thanks and Regards,
SivaRamaKrishnaRaju..