This is a migrated thread and some comments may be shown as answers.

parameters

4 Answers 91 Views
EntityFrameworkDataSource
This is a migrated thread and some comments may be shown as answers.
Rayne
Top achievements
Rank 1
Rayne asked on 22 Nov 2011, 08:30 PM
Can we use parameters in the query?

4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 23 Nov 2011, 11:44 AM
Hello Rayne,

Can you please provide some kind of a real-world example? How do you want to use parameters? For example, suppose that we have an ObjectContext called NorthwindEntities and it has an ObjectSet property called Customers, how would you go about parameters if you were working solely with Entity Framework?

We are looking forward to hearing from you.

Best wishes,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Rayne
Top achievements
Rank 1
answered on 28 Nov 2011, 05:52 PM
What if I don't want to return all 50,000 Customers? The demo shows that the QueryName is Customers (which would be the whole collection). Even then, in my scenario, I have an IsDeleted flag on my entity, so I'd want to return all "Customers" where IsDeleted is false.


0
Accepted
Rossen Hristov
Telerik team
answered on 29 Nov 2011, 09:33 AM
Hello Rayne,

That is called filtering and is possible of course. If you have a RadGridView or RadDataFilter bound to your data source control then filtering will occur out-of-the-box when the user filters through the UI. No code needed.

In case you want to filter programmatically, you can add a FilterDescriptor instance to the FilterDescriptors collection of the control. For example:

this.radEntityFrameworkDataSource.FilterDescriptors.Add(new FilterDescriptor("IsDeleted", FilterOperator.IsEqualTo, false));

This will automatically append a Where clause on the query and send it to the server.

You can create more complex filtering criteria by combining them with CompositeFilterDescriptor's.

The same applies for sorting, grouping and paging. For example, if you sort RadGridView, this will automatically be transferred to the server by appending an OrderBy clause on the query. Grouping will append a GroupBy clasue.

You can bind a RadDataPager to the data source control and you will get paging out-of-the-box as well. It will apppend Skip and Take clauses.

All of this happens without a single line of code.

I have attached a sample project which you can play around it and test this functionality. You might need to point the connection string to your local instance of AdventureWorks.

Let me know if I can help with anything else.

Kind regards,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Rayne
Top achievements
Rank 1
answered on 29 Nov 2011, 02:25 PM
Thanks. I didn't realize that the filtering was done on the server.
Tags
EntityFrameworkDataSource
Asked by
Rayne
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Rayne
Top achievements
Rank 1
Share this question
or