Questions tagged [linq2db]

LINQ to DB is a fast LINQ database access library offering a simple, light, fast, and type-safe layer between your POCO objects and your database.

LINQ to DB is a fast LINQ database access library offering a simple, light, fast, and type-safe layer between your POCO objects and your database.

Architecturally it is one step above micro-ORMs like Dapper, Massive, or PetaPoco, in that you work with LINQ expressions, not with magic strings, while maintaining a thin abstraction layer between your code and the database. Your queries are checked by the C# compiler and allow for easy refactoring.

However, it's not as heavy as LINQ to SQL or Entity Framework. There is no change-tracking, so you have to manage that yourself, but on the plus side you get more control and faster access to your data.

See Wiki for more details.

Code examples and demos can be found here.

183 questions
0
votes
0 answers

Linq2Db wrong JOIN

I'm using Linq2Db from a long time and I've never have to face a mistake in the queries. I've a function returning an IQueryable and then another method where I compose another query using the first one as a base. await using var db = new…
Marco
  • 56,740
  • 14
  • 129
  • 152
0
votes
1 answer

linq2db CreateTempTableAsync throws "unexpected existing transaction"

We use linq2db to create a temporary table and populate it using the following code. The data connection linq2db needs is created using the ef core DbContext. // _context is an EFCore DbContext var db = _context.CreateLinqToDbConnection();…
SkAl
  • 1
0
votes
1 answer

linq2db throws exception when filtering by nested collection

We are using .NET Core 3.1, Microsoft.EntityFrameworkCore 3.1.9, Npgsql 4.1.9 and linq2db.EntityFrameworkCore 3.7.0. We have the following 2 scaffolded classes: [Table("testrunconfig", Schema = "fit")] public partial class Testrunconfig { public…
Sam Carlson
  • 1,891
  • 1
  • 17
  • 44
0
votes
1 answer

How do I get and log all Linq To Db queries to a database table?

I need to get the execution plan of all Linq To Db queries for my application, and them to a database table for any query that takes longer than 2 minutes. How do I get an execution plan, and is there one place where I can do this for all queries in…
Scott
  • 2,456
  • 3
  • 32
  • 54
0
votes
1 answer

Linq2DB map property to result of SQL function

I have SQLite database with table Reports. CREATE TABLE IF NOT EXISTS Reports ( Id INTEGER PRIMARY KEY AUTOINCREMENT, ReportName TEXT NOT NULL UNIQUE, CreatedAt REAL NOT NULL ) It contains column CreatedAt and the date is…
Ondrej
  • 596
  • 5
  • 14
0
votes
1 answer

linq2db after update to 5.0 / 'Invalid configuration. Configuration string is not provided

I've updated to linq2db 5.0 and when I try to execute it I got the error ': 'Invalid configuration. Configuration string is not provided.' ' Here's my configuration public static void RegisterLinq2DbConnection(this IFunctionsHostBuilder builder) { …
advapi
  • 3,661
  • 4
  • 38
  • 73
0
votes
1 answer

How do I fill a child list inside a parent list using linq2db in a single query in my .net core app?

I am trying to query my database to return turn reports with any attachments included. I need a list of turn report items which are returned by date, and then for each report I want it to also return all of the attachments associated with the turn…
Avi4nFLu
  • 152
  • 8
0
votes
0 answers

LinqToDB.EntityFrameworkCore IgnoreFilters() does not disable global filters on some queries

I use global filter from Microsoft.EntityFrameworkCore 3.1.9 on my table Object (…HasQueryFilter(x => !x.IsDeleted) I am also using LinqToDB.EntityFrameworkCore 3.7.0 for updating and deleting records in db. To disable filter on queries generated…
Svit_O
  • 1
  • 1
  • 2
0
votes
1 answer

Get name from TableAttribute Linq2DB

I'm using Linq2DB, LinqToDB.Mapping to map the tables from database. The class name has a Data Annotation named "Table" to specify the name of the table in de DB. For example: [Table(@"EXAMPLE_ONLINE")] public class Example { …
qhart
  • 29
  • 6
0
votes
0 answers

convert ms sql sub query in select clause to linq2db C#

Can some one help me in converting below ms sql query to linq2db c# query? I could not find any reference in linq2db documentation. Any help or url to an example is highly appreciated. SELECT p.Id as ProductId, (SELECT STRING_AGG(sao.Name, ',') …
umsateesh
  • 163
  • 1
  • 1
  • 12
0
votes
1 answer

How to create a expression of ClickHouse countIf function for linq2db?

How I can migrate clickhouse countIf function to linq2db? Example: from => SELECT customer_id, countIf(customer_id, active_month between 0 and 1) as active_month1 FROM myt_table GROUP BY customer_id to => from x in my_table group x by…
0
votes
0 answers

Read-only temporal table columns with Linq2DB

I have this table with temporal columns: CREATE TABLE [dbo].[Profile]( [Id] [int] IDENTITY(1,1) NOT NULL, [CreatedDate] [datetime2](7) GENERATED ALWAYS AS ROW START NOT NULL, [UpdatedDate] [datetime2](7) GENERATED ALWAYS AS ROW END NOT…
Hugo Forte
  • 5,718
  • 5
  • 35
  • 44
0
votes
1 answer

How can I get a record in any table use linq2db and generics

How can I use any table name for get any record from any table use Linq2db. I try use generic, but I don't understand how I have to set the current table. public void ObjectGetById(int id, ref T obj) { string tbl = obj.GetType().Name; …
0
votes
0 answers

Linq2DB Use Converter when using SQL Server DateTime2 DbType

I would like to strictly convert DateTime Values to UTC when target Column is a DateTime2 DB Type. Found some resources which are mentioning the .SetConverter - Method. But whatever i do (As you can see in my code below i was trying to specify the…
fops
  • 384
  • 1
  • 13
0
votes
1 answer

Linq2Db streaming from database (ClickHouse)

Does the Linq2Db have a common approach for streaming results from the database? This can be a raw response from the database or IEnumerable (which are internally obtained from the stream) I would like to get the following behavior: a…
Jewry
  • 1
  • 2