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

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

1 Answer 53 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dilshod
Top achievements
Rank 1
Dilshod asked on 14 Jan 2016, 04:07 AM

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

1 Answer, 1 is accepted

Sort by
0
Simeon Simeonov
Telerik team
answered on 18 Jan 2016, 03:02 PM
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.
Tags
Development (API, general questions)
Asked by
Dilshod
Top achievements
Rank 1
Answers by
Simeon Simeonov
Telerik team
Share this question
or