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
1
vote
2 answers

linq2db - server side bulkcopy

I'm trying to do a "database side" bulk copy (i.e. SELECT INTO/INSERT INTO) using linq2db. However, my code is trying to bring the dataset over the wire which is not possible given the size of the DB in question. My code looks like this: using (var…
gatapia
  • 3,574
  • 4
  • 40
  • 48
1
vote
1 answer

Add or remove column mapping at runtime for linq2db

I have a scenario where if certain features are deployed then a number of columns will be there in some tables otherwise won't so the mapping of Entities and Columns is not static. I need to add/remove the mapping at runtime. Is there any way?
bjan
  • 2,000
  • 7
  • 32
  • 64
1
vote
0 answers

linq2db update with CTE on MySql 8

This question is about linq2db.MySql 3.1.5 and MySQL 8.0.21 I am getting "You have an error in your SQL syntax..." when trying to run an update (marking duplicate emails) using CTE on MySql as per below var cte = ( …
1
vote
0 answers

How to load child collection in linq2Db?

I have created below tables in my sql. create table Department ( Id uniqueidentifier primary key not null, Name nvarchar(255), IsActive bit ) create table Employee ( Id uniqueidentifier primary key not null, Name nvarchar(255), …
Glenn singh
  • 233
  • 1
  • 6
  • 18
1
vote
1 answer

LINQ 2 DB insert dynamic into table

I want to use dynamic in order to be able to choose which columns to define and those I want to let the DB set the DEFAULT value. Is there a way to insert a dynamic into a table and return the Id? I tried various overloads both on DataConnection and…
Sergio
  • 2,078
  • 3
  • 24
  • 41
1
vote
1 answer

Linq2db: filter by nested property field

I'm using a linq2db ORM in my project and I have the following query: var query = from t in _db.Transactions from a in _db.Accounts.LeftJoin(a => a.Id == t.AccountId) from u in _db.Users.LeftJoin(u => u.Id == a.UserId) …
Grigory Zhadko
  • 1,484
  • 1
  • 19
  • 33
1
vote
1 answer

Linq2db: join tables with eager loading

I'm using linq2db ORM in my project and have the following database schema (simplified): I have the following method to get information about the user: public async Task GetUser(int id) { var user = await ( from u in _db.Users …
Grigory Zhadko
  • 1,484
  • 1
  • 19
  • 33
1
vote
1 answer

Group by week by using Linq2DB for PostgreSQL

I am using Linq2DB for PostgreSQL. I need to group the data by week in Linq. Below is my code: Func weekProjector = d => CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(d, …
kchong Hoh
  • 31
  • 6
1
vote
1 answer

How to create database in Microsoft SQL Server using linq2db by code first approach in .NET CORE 2.2

Created new project in .net core 2.2 and installed nuget package linq2db.sqlserver using this package i am able to do CRUD with database first approach but i need to know how to do CRUD using code first approach.
RajPawar
  • 11
  • 2
1
vote
1 answer

Pass Expression instead lambda

all! I'll try to write extention for add mapping db column by defaults. I using linq2db this is my method public static void EntityWithDefaults(this FluentMappingBuilder fluentMappingBuilder) { …
RomanReaL D
  • 101
  • 5
1
vote
2 answers

System.TypeLoadException Could not load type 'Microsoft.EntityFrameworkCore.Query.RelationalQueryContextFactory'

I have written basic simple query which was working before when I was using .net core 2.2 (I have used linq2db.EntityFrameworkCore) projectContext.DocumentAnnotation.ToLinqToDBTable().InsertWithIdentity(() => new DocumentAnnotation { Name = name,…
1
vote
1 answer

union of different types using linq2db

I have type definition of DocumentField_1 & DocumentField_2, which is totally different. DocumentField_1 has records if assigned value is true otherwise record will not be there, so it is of boolean type. and DocumentField_2 has value with date. I…
Anonymous Creator
  • 2,968
  • 7
  • 31
  • 77
1
vote
0 answers

Mocking extension methods of linq2db

Currently i am writing unit tests for repository, wrapping linq2db methods. I am trying to mock a simple select method but of course you can't mock extension methods like GetTable() or Insert(item). What i am currently trying to do is set up a…
1
vote
3 answers

Connecting .NET Core web application to sap hana (could not load assembly)

I am using linq2db as ORM for my web application project (ASP.NET Core 2.2) with SAP HANA database. When I run my code including database queries I receive the following error (first 2 rows): System.IO.FileNotFoundException: Could not load file or…
1
vote
1 answer

Generating POCO classes with T4Model in linq2db for selected tables only

I am using linq2db as ORM for my web application project (ASP.NET Core 2.2) with SQL Server database. The database consists of over 500 tables and only a subset of tables is relevant to the web application. Therefore, I'd like to only map the…
Manderhub
  • 25
  • 1
  • 7