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

Client Side Binding - SQL, Linq

9 Answers 193 Views
Grid
This is a migrated thread and some comments may be shown as answers.
acm2001
Top achievements
Rank 2
acm2001 asked on 17 Feb 2009, 01:50 PM
I am trying  to implement the example at
http://blogs.telerik.com/kevinbabcock/posts/09-02-10/RadTips_Episode_14_Using_Declarative_Client-Side_Databinding_in_the_RadGrid_for_ASP_NET_AJAX_Part_2.aspx
which shows a great way to easily bind data at the client side. It really looks to reduce the postback overhead.

I have it half working using an SQL statement ( Dim PostList As Object = Post.GetPostsByDaysOld(1)) from a class I created, however i cannot implement the :
datalist= datalist.skip(startIndex).Take(rowCount) command since this is for Linq

I actually want to use linq not SQL and am currently using linq through the openaccess ORM.

When i switch the data source to be
 Dim postlist As IQueryable = (From p In scope.Extent(Of BlogLinkVB.Post())() Select p).Where(filterExpressions).OrderBy(sortExpressions) or more plainly
Dim postlist As IQueryable = (From p In scope.Extent(Of BlogLinkVB.Post())() Select p)

I get an error saying the class is not persistent.

I checked the forward mapping and looked inside the class. they are definatley persistent
I have Imports System.Linq.Dynamic set
how can i move forward?
thanks
alan








9 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 18 Feb 2009, 05:24 PM
Hello,

You may check this blog post for information on how to implement RadGrid client-side binding using OpenAccess and WCF services.

Let us know if you need further assistance.

Regards,
Rosen
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
acm2001
Top achievements
Rank 2
answered on 19 Feb 2009, 05:16 AM
this article complicates the whole process instead of keeping the simple coding of the original article. The example is only in C#. It appears in many of the examples that C# has become the dominant language for telerik and VB is getting the after thought treatment.

I would like to understand the article
http://blogs.telerik.com/kevinbabcock/posts/09-02-10/RadTips_Episode_14_Using_Declarative_Client-Side_Databinding_in_the_RadGrid_for_ASP_NET_AJAX_Part_2.aspx
and know why the error is appearing.
this article was only written 10 days ago. I doubt it has been superseeded yet.

Alan
I am trying  to implement the example at
http://blogs.telerik.com/kevinbabcock/posts/09-02-10/RadTips_Episode_14_Using_Declarative_Client-Side_Databinding_in_the_RadGrid_for_ASP_NET_AJAX_Part_2.aspx
which shows a great way to easily bind data at the client side. It really looks to reduce the postback overhead.

I have it half working using an SQL statement ( Dim PostList As Object = Post.GetPostsByDaysOld(1)) from a class I created, however i cannot implement the :
datalist= datalist.skip(startIndex).Take(rowCount) command since this is for Linq

I actually want to use linq not SQL and am currently using linq through the openaccess ORM.

When i switch the data source to be
 Dim postlist As IQueryable = (From p In scope.Extent(Of BlogLinkVB.Post())() Select p).Where(filterExpressions).OrderBy(sortExpressions) or more plainly
Dim postlist As IQueryable = (From p In scope.Extent(Of BlogLinkVB.Post())() Select p)

I get an error saying the class is not persistent.

I checked the forward mapping and looked inside the class. they are definatley persistent
I have Imports System.Linq.Dynamic set
how can i move forward?
thanks
alan




0
Rosen
Telerik team
answered on 23 Feb 2009, 11:41 AM
Hi,

I have attached a modified version of the example in question but using OpenAccess. Please take a look and let us know if this helps.

All the best,
Rosen
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
acm2001
Top achievements
Rank 2
answered on 24 Feb 2009, 06:06 AM
Thanks for your reply and code. this is helpful.

One thing i cannot understand is why this works:
 Dim postlist = scope.Extent(Of BlogLinkVB.Post)()
 postlist = postlist.Where(filterExpressions).OrderBy(sortExpressions)

but this does not work:
 Dim postlist = From p In scope.Extent(Of BlogLinkVB.Blog)() Where p.Domains.Any(Function(o) o.DomainID = CurrentDomainID) select p
 postlist = postlist.Where(filterExpressions).OrderBy(sortExpressions)

How can i get this complex query to work in my code?
Whenever I run this with the webmethod i get no data. If i run the same query on a normal grid i get the data

i dont want to change the ordering and filtering even on the postback, i just want to be able to query the original dataset before we bind the grid.

Can I only perform this on a clean scope.extent call or can i query the scope.extent first?

Thanks
Alan
0
Zoran
Telerik team
answered on 26 Feb 2009, 04:36 PM
Hello Alan

The reason that you get the exception when executing your second query is that you try to use multiple "Where" clauses and that case is still not implemented by OpenAccess. I can assure you that this support in Linq scenarios will be available in the near future.

Please do not hesitate to contact us for any other issue concerning our products.

Best wishes,
Zoran
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
acm2001
Top achievements
Rank 2
answered on 26 Feb 2009, 11:49 PM
Thanks for your reply

This by iteself also does not work
Dim postlist = From p In scope.Extent(Of BlogLinkVB.Blog)() Where p.Domains.Any(Function(o) o.DomainID = CurrentDomainID) select p

but this will

Dim postlist = From p In scope.Extent(Of BlogLinkVB.Blog)() Where p.Blog.DomainID = 27 select p

I assume the top query is a multiple where query.
This query works in normal linq grid routines just not with the client side binding
Should that be the case?

Also, can you provide a workaround with OQL?
When I try an OQL query I have a problem with the skip(startIndex).Take(rowcount) code which an error saying Skip is not a member of the Telerik.OpenAccess.IQueryResult

Alan



0
Zoran
Telerik team
answered on 27 Feb 2009, 04:44 PM
Hi Alan

The latest query you reported should be a working one. Here is how an OQL version of the query should look like with Take() and Skip() also implemented.

Query<BlogLinkVB.Blog> oqlQuery = scope.GetOqlQuery<BlogLinkVB.Blog>("Select b from BlogExtent as b, b.Domains as bd where bd.DomainId==$1");  
            int CurrentDomainId = 100;  
            int rowCount = 10;  
            int startIndex = 112;  
            oqlQuery.MaxResultCount = rowCount;  
            oqlQuery.Skip = startIndex;  
            QueryResultList<BlogLinkVB.Blog> resultOql = oqlQuery.ExecuteList(CurrentDomainId); 

If you still have problems with presentation of the returned results, please consider sending us a small runnable application (attached to a formal ticket) thus we will be able to debug it locally and provide you with more to-the-point answer.

Sincerely yours,
Zoran
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
acm2001
Top achievements
Rank 2
answered on 02 Mar 2009, 05:57 PM
Thank you
Very helpful. Telerik has the best service!
I got the query to work and populated the grid with JSON

for info, here was my completed query (it is a query with a link table, A, B, AB style)

        Dim querystring As String = "Select * from PostExtent as p WHERE EXISTS pd IN p.Blog.Domains: (pd.DomainID=$1 AND pd.Status = 1) AND p.PubDate >= $2 AND p.Blog.Status = 1  ORDER BY p.PubDate DESC"
        Dim oqlQuery = scope.GetOqlQuery(Of BlogLinkVB.Post)(querystring)
        Dim result2 As QueryResultList(Of BlogLinkVB.Post) = oqlQuery.ExecuteList(CurrentDomainID, StartDate)
        Dim count As Integer = result2.Count
        Dim postlist = result2.Skip(startIndex).Take(rowCount)

I had one remaining problem, i wanted to set a hyperlink in the grid
 <telerik:GridHyperLinkColumn DataTextField="Title"
                        DataType="System.String"
                        DataNavigateUrlFields="link"                        
                        HeaderText="Post"
                        UniqueName="Title">
                    </telerik:GridHyperLinkColumn>

and also set a tooltip.

I could not get the datanavigateurlfields to show any data and i could not find how to set the tooltip.
I noticed you must have a DataNavigateUrlFormatString declaration or nothing will show from the DataNavigateUrlFields, but when i set the DataNavigateUrlFormatString="{0}" and pass the "link" variable in as a uri such as "http://www.differentsite.com" the result comes up in the browser as "http://www.thissite.com/http://www.differentsite.com"

I need to fix this and find a way to set the tooltip . I have the tooltip working on my normal ajaxed grid like this Text='<%#Eval ("Title") %>'

On the declarative grid even static text on the text field for GridHyperLinkColumn does not show a tootip
 <telerik:GridHyperLinkColumn DataTextField="blogtitle"
                        DataType="System.string"
                        DataNavigateUrlFields="blogtitle"
                        DataNavigateUrlFormatString="/blog/tag.aspx/{0}"                          
                        Text="sss"                        
                        HeaderText="Blog"
                        UniqueName="BlogTitle">
                    </telerik:GridHyperLinkColumn>
Thanks
Alan


any thought?
Alan


0
Sebastian
Telerik team
answered on 03 Mar 2009, 08:22 AM
Hello acm2001,

Thank you for the nice words about the support service we provide.

How to set up the DataNavigateUrlFields/DataNavigateFormatString properties of built-in GridHyperlinkColumn you can see from the following demo of the product:

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx (see the hyperlink column definition)

Additionally, to define tooltips for the hyperlinks/cells in the grid, review the solution presented in this help article.

Best regards,
Sebastian
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
acm2001
Top achievements
Rank 2
Answers by
Rosen
Telerik team
acm2001
Top achievements
Rank 2
Zoran
Telerik team
Sebastian
Telerik team
Share this question
or