Print Page | Close Window

Union on EntityQueryPagedCollectionView

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2568
Printed Date: 13-Jun-2026 at 4:31pm


Topic: Union on EntityQueryPagedCollectionView
Posted By: rowell_21
Subject: Union on EntityQueryPagedCollectionView
Date Posted: 16-Mar-2011 at 11:27pm
Is it possible to use union to add a new row on top of the results being queried?

I need to add something like "All Records" in the results and I'm using EntityQueryPagedCollectionView object and does not have a way to modify it before binding to a grid.

My results should look like this:

Id -  Name
0 -  All Records
1 -  Record1
2 -  Record2
3 -  Record3
...


I used to do it in stored procedure by having a union of the "All Records" row to the actual resort before returning it.


Thanks.



Replies:
Posted By: DenisK
Date Posted: 22-Mar-2011 at 3:43pm
Hi rowell_21;

I'm not sure I follow your question. EntityQueryPagedCollectionView only works with an EntityQuery<T> and you can't access each individual row to modify the results.

Perhaps if you can elaborate your use case further, I can give you better suggestions.


Posted By: rowell_21
Date Posted: 24-Mar-2011 at 8:54am
Hi DenisK,

Thank you for your response.
Here's what I need to do:

I have one table named "Services" which has two columns, [ServiceId] int and [ServiceName] varchar.

I need to bind this to a grid but I need to have a row that has zero(0) for ServiceId and "All Services" for ServiceName.

I used to do this in stored procedure by a sample query below:

SELECT 0 AS [ServiceId], 'All Services' AS [ServiceName]
UNION
SELECT ServiceId, ServiceName FROM Services

this would result to:

ServiceId   ServiceName
0               All Services
1               Service1
2               Service2
3               Service3
.....


I would like to put a paging in my results to minimize traffic when loading all results.

Thanks.


Posted By: DenisK
Date Posted: 24-Mar-2011 at 5:19pm
Hi rowell_21;

Unfortunately what you're asking won't work using EntityQueryPagedCollectionView. I only have 2 suggestions at this time.

1. Try using a different type of grid.

2. Don't use Union and instead store that record in the database.



Print Page | Close Window