How do you create a CTE with an IList<> passed as a parameter?
See original GitHub issueMy function currently takes an IList<> as a parameter. I need to be able to convert it to a CTE that is joined on in a SQL statement.
When I try to convert it to an IQueryable object and convert it to a CTE like so:
var myQueryable = myList.asQueryable<T>();
var myCTE = myQueryable.AsCte();
But myCTE object doesn’t reflect having any values from the list.
var myQueryableType = myQueryable .GetType();
This shows that the type is System.Linq.EnumerableQuery as well.
The myCTE object also has the message: “There is no method ‘AsCte’ on type ‘LinqToDB.LinqExtensions’ that matches the specified arguments”.
Issue Analytics
- State:
- Created 3 years ago
- Comments:21 (16 by maintainers)
Top Results From Across the Web
sql - Is there any way to pass parameters to CTE?
A CTE doesn't need parameters. It can't exist on its own, it's always part of a query so it already has access to...
Read more >Is it possible to use a paramter in the with clause?
Your question is not very clear, but yes, you can refer to variables in a Common Table Expression (CTE), which I assume that...
Read more >passing a variable to CTE in a view
Hi ,. I have a view which contains a CTE and I need to pass the parameter inside the CTE. our application is...
Read more >DynamicQueryEngine Class
Creates a new Select Query which is ready to use, based on the query parameters specified. (Overrides DynamicQueryEngineBase.CreatePagingSelectDQ( ...
Read more >How to avoid passing property names as strings using C# 3.0 ...
Referencing property names via strings is evil. Consider this simplistic example: private int _myProperty; public int MyProperty { get ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
There are only four IQueryable sources supported in library
Any of them are complicated. I appreciate your interest but it can be really challenging task from the start. For example implementing CTE took about month of my free time to understand how to do that correctly. It is not an just create SQL AST which generates VALUES, but it is also good knowledge in our LINQ parser.
I’ll give you small example which problems needs to be solved: We have array
Let’s write query
In this query, we have used only two fields from
data
array. So only two fields should be used in SQL generation. Another trick with reusing values from other table:Also If database do not support VALUES, we have to mimic it by UNION ALL A lot of nuances here. Really. That’s why i’m trying to prioritize this task implementation.
If you still interested, i can start pointing you in right direction.
Yeah, I’m going to write a series of new tests for sure. Need to test that the constant array works for insert, update, delete, merge, and regular select. I’ll put in
[ActiveIssue]
tests for all of the same for the outer apply version, knowing those won’t work in v1.Thanks for the add’l places to look for changes though.