Hi,
I know the answer is going to be with my query, however we have 2,500 records being returned using RIA. I have adjusted the query as the database has a large amount of columns and we only need a small subset of the data to be shown in the grid. I have adjusted the loading page size to 500 in the data source, however when running an SQL trace the query is returning all records and the paging is being done on the client side. Therefore the binding is very slow. Could you look at my query and advise why this is not paging or how to modify this;
I know the answer is going to be with my query, however we have 2,500 records being returned using RIA. I have adjusted the query as the database has a large amount of columns and we only need a small subset of the data to be shown in the grid. I have adjusted the loading page size to 500 in the data source, however when running an SQL trace the query is returning all records and the paging is being done on the client side. Therefore the binding is very slow. Could you look at my query and advise why this is not paging or how to modify this;
var query = from person in this.ObjectContext.data_PERSON
join roles in this.ObjectContext.data_ROLE on person.rowguid equals roles.personguid into tempRole
select new
{
person.firstname, person.lastname, person.emailprimary, person.rowguid, person.companyguid,
tempRole = (from role in tempRole
select new
{
role.rowguid, role.linemanager, role.personaljobtitle,
role.orglevel1, role.orglevel2, role.orglevel3, role.orglevel4, role.orglevel5,
}).FirstOrDefault()
};
//company
var companysecurity = (from c in this.ObjectContext.system_SECURITY_ADMIN_COMPANY
where c.securityguid == u.AdminSecurityGuid
select c.companyguid).Distinct().ToList();
if (companysecurity.Count != 0)
query = from q in query where companysecurity.Contains(q.companyguid) select q;
//orglevel 1
var orglevel1security = (from o in this.ObjectContext.system_SECURITY_ADMIN_ORGLEVEL1
where o.securityguid == u.AdminSecurityGuid
select o.orglevel1guid).Distinct().ToList();
if (orglevel1security.Count != 0)
query = from q in query where orglevel1security.Contains(q.tempRole.orglevel1) select q;
//orglevel 2
var orglevel2security = (from o in this.ObjectContext.system_SECURITY_ADMIN_ORGLEVEL2
where o.securityguid == u.AdminSecurityGuid
select o.orglevel2guid).Distinct().ToList();
if (orglevel2security.Count != 0)
query = from q in query where orglevel2security.Contains(q.tempRole.orglevel2) select q;
//orglevel 3
var orglevel3security = (from o in this.ObjectContext.system_SECURITY_ADMIN_ORGLEVEL3
where o.securityguid == u.AdminSecurityGuid
select o.orglevel3guid).Distinct().ToList();
if (orglevel3security.Count != 0)
query = from q in query where orglevel3security.Contains(q.tempRole.orglevel3) select q;
//orglevel 4
var orglevel4security = (from o in this.ObjectContext.system_SECURITY_ADMIN_ORGLEVEL4
where o.securityguid == u.AdminSecurityGuid
select o.orglevel4guid).Distinct().ToList();
if (orglevel4security.Count != 0)
query = from q in query where orglevel4security.Contains(q.tempRole.orglevel4) select q;
return query.ToList().AsQueryable().Select(
p => new data_PERSON
{
rowguid = p.rowguid,
emailprimary = p.emailprimary,
firstname = p.firstname,
lastname = p.lastname,
data_CURRENT_ROLE = (new data_ROLE
{
rowguid = p.tempRole.rowguid,
linemanager = p.tempRole.linemanager,
personaljobtitle = p.tempRole.personaljobtitle,
})
}).OrderBy(o=>o.firstname);
}