How express `SELECT1 UNION ALL SELECT 2` sub-query in Linq2Db
See original GitHub issueI have a query which uses IN
clause:
var query = dataContext.ExecuteObject<Card>()
.Where(x => x.Version == workingVersion);
.Where(x => cities.Contains(x.CityId));
which is not very effective, because cities
collection is quite big (and provided by user request). I would like to replace IN
clause with INNER JOIN
like that:
[x1].CityId IN (1, 2, 3, 4)
INNER JOIN (SELECT 1 AS Id UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4) [c] ON [c].Id = [x1].[CityId]
How can I express such SELECT
UNION
in Linq2Db?
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
union of different types using linq2db
select 'True' from DocumentField_1 where DocumentField_1.DocumentId = 2 union all select CONVERT(varchar, value) from DocumentField_2 where ...
Read more >Joining two subqueries with union all and join leads to ...
CustomerID IN ( SELECT Id FROM @ids ) UNION ALL SELECT '0' ) -- Join t1 to the top half of the original...
Read more >How to use"Union ALL" to join sql queries each containing ...
I have 2 sql statements and each sql statement is having orderby clause when i am use" UNION ALL " to join them...
Read more >Writing Better Performing Queries with LINQ on EF Core 6.0 ⚙️
These two queries will translate to same SQL if you keep an eye out using SQL Server Profiler. SELECT [e].[Name] FROM [Employees] AS...
Read more >Subqueries - Azure Cosmos DB for NoSQL
Subqueries in Azure Cosmos DB for NoSQL · SELECT VALUE COUNT(1) FROM products p JOIN t in p. · SELECT VALUE COUNT(1) FROM...
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
@NickAb, you can create temp table using linq2db, bulk copy data to that table and use inner join. It sholuld be more effective.
Solution needed, or we can close an issue?