TelerikContext.ExecuteQuery<T>() doesn't return IQueryable<T>

2 posts, 0 answers
  1. Dilshod
    Dilshod avatar
    23 posts
    Member since:
    Feb 2012

    Posted 13 Jan Link to this post

    Hi,

    Question 1: In my project I need to do some advanced dynamic query that I can't do with Linq or DynamicLinq. Therefore I want to use context.ecxecuteQuery<T>, but I realized that it doesn't return IQueryable<T>. Because I would like to do more filtering on the first query that I want to execute. Is it all possible that somehow I can get IQueryable<T>? 

    Question 2: I tried it with Entity Framework 6 and it seems it works as expected(returns IQueryable<T>). The problem here is then if I bring the objects through the Entity Framework then those objects are not tracked by Telerik Data Access. Is it possible to add the objects the came not through Telerik Data Access to the Telerik context?

     

    What I am trying to do is recursive query using CTE and doing full text search on it with using join.

    Please correct me if I am on a wrong path.

     

    Thanks,

    Dilshod Niyozov

  2. Simeon Simeonov
    Admin
    Simeon Simeonov avatar
    24 posts

    Posted 18 Jan Link to this post

    Hi Dilshod,

    Thank you for contacting us. 

    1/ Regarding your first question, there is a possible work around you can try. You can use the string extension method SQL<T>(), that is defined in the Telerik.OpenAccess namespace. This method allows you to plug in the Where clause of a LINQ expression a raw SQL statement. Please consider the following example:

    var filteredItemsQuery = from item in context.GetAll<Item1>()
              where "{0} like {1}".SQL<bool>(item.Name, "%First%")
              select item;
    var result = filteredItemsQuery.ToList();

    Here a collection of items is filtered by the value in the Name column, by directly plugging the SQL to be used for the filter.

    2/ Regarding your second question - it is possible to attach to a DataAccess context an object that is not retrieved using that context. In your specific case however this may not work as advertised, because it is possible that EntityFramework is enhancing the objects in some way which makes them impossible to handle by the DataAccess context. I would suggest trying this approach only as a last resort. For more information, on how to attach and detach objects to the DataAccess context, please look at this article.

    I hope you find this information helpful.

    Regards,
    Simeon Simeonov
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  3. DevCraft banner
Back to Top