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

WCF and stored procedure

3 Answers 151 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Growls
Top achievements
Rank 1
Growls asked on 22 Jul 2009, 06:57 AM
Hi I have a web service I am trying to get working to bind data to grid:
 [OperationContract] 
        public ResultData GetDataAndCount(int startRowIndex, int maximumRows, string sortExpression, string filterExpression) 
        { 
            GridBindingData data = RadGrid.GetBindingData("Waivenet.DataClassesDataContext""productAttrib", startRowIndex, maximumRows, sortExpression, filterExpression); 
            ResultData result = new ResultData(); 
            //var products = DataClassesDataContext.uspGetProductsByCategory(SessionWrapper.userID); 
            //data.Data = DataClassesDataContext.uspGetProductsByCategory(SessionWrapper.userID); 
            result.Data = data.Data.OfType<DataClassesDataContext.uspGetProductsByCategory(SessionWrapper.userID)>().Select(p => new Product() 
            { 
                productID = p.productID, 
                productCode = p.productCode, 
                name = p.name, 
                description = p.description, 
                quantType = p.quantType, 
                sellPrice = p.sellPrice, 
                uom = p.uom, 
                imageThumb = p.imageThumb, 
                categoryID = p.categoryID 
            }).ToList(); 
            result.Count = data.Count; 
             
            Debug.WriteLine("row index: " + startRowIndex + ", max rows:" + maximumRows + ", sort expression: " + sortExpression + ", filter expression: " + filterExpression); 
            return result; 
        } 
the above doesnt work, anyone have an example of a working WCF webservice that is bound from a stored procedure?

3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 27 Jul 2009, 08:43 AM
Hello Craig,

Indeed RadGrid.GetBindingData essentially does same as what LinqDataSource does and the result returned from Data property of GridBindingData is List<object> returned from selection of LinqDataSource control.

Regards,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Growls
Top achievements
Rank 1
answered on 28 Jul 2009, 10:32 PM
result.Data = wnDataContext.ExecuteQuery<uspGetProductsByCategoryResult>("uspGetProductsByCategory", SessionWrapper.currentCategory).Select(p => new Product() 
            { 
                pproductID = p.productID, 
                pproductCode = p.productCode, 
                name = p.name, 
                description = p.description, 
                quantType = p.quantType, 
                sellPrice = p.sellPrice, 
                uom = p.uom, 
                imageThumb = p.imageThumb, 
                categoryID = p.categoryID 
            }).ToList(); 
            resultresult.Count = result.Data.Count; 
the above works to assign the necessary data to the "result" class. my problem is i need to have it working with the Start Row Index, Max Rows, and the sort/filter expressions. it would mean adding a WHERE clause to the LINQ query, but I am not sure what format RadGrid client side is sending through the sort/filter.

I am using this as a base template: http://demos.telerik.com/aspnet-ajax/grid/examples/clientmasterdetails/defaultcs.aspx

0
Nikolay Rusev
Telerik team
answered on 31 Jul 2009, 03:12 PM
Hello Craig,

You can control the type of sort/filter expressions returned from RadGrid by setting the following properties in ClientSettings.DataBinding section of RadGrid:
SortParameterType, FilterParameterType to one of the following types Linq,List,Oql,String

Sincerely yours,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Growls
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Growls
Top achievements
Rank 1
Share this question
or