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

System.NullReferenceException in Linq2Db "BeginTransactionAsync"

I'm coming across a System.NullReferenceException: Object reference is not set to an instance of an object when trying to create a DataConnectionTransaction via LinqToDb. The top two items within the parsed call stack are as follows: { …
tpooch21
  • 59
  • 1
  • 5
0
votes
1 answer

Slow LINQ query because of Where+ToDictionary

I have this query that I need to run: IEnumerable merchants = from i in ( from m in d.GetTable() join mtp in d.GetTable() on m.Id equals mtp.MerchantId into mtps …
walruz
  • 1,135
  • 1
  • 13
  • 33
0
votes
1 answer

NodaTime with Linq2Db

How can I configure T4 POCO generation in Linq2Db to generate models that use NodaTime types instead of System.DateTime? I'm using PostgreSQL with Npgsql.
zigzag
  • 579
  • 5
  • 17
0
votes
1 answer

Linq2Db Async Insert - Cannot access a disposed object. ObjectDisposed_ObjectName_Name'

I have been working on my own project that I have been using .Net Core 3.1 and Linq2b ORM tool for. I have a problem that is about inserting data by using async metot. I want to insert a log data. There is a method that is called…
Ismail Dogan
  • 295
  • 2
  • 20
0
votes
1 answer

Linq2Db: How to use function Sql.Ext.ListAgg?

I have a model with table Position where are multiple rows with same column value CompanyId and I'd like to group these rows and concat another column Email into comma separated list. My database is IBM DB2 for i and in SQL I can write query like…
Ondrej
  • 596
  • 5
  • 14
0
votes
1 answer

Entity Framework Linq2Db Translation

I am upgrading a website that used Entity Framework and now uses Linq2Db. I notice Linq2Db has no navigation properties. How would I translate this code from Entity Framework? I need to return an order with a list of order items, shipments, and…
Joseph Anderson
  • 4,114
  • 4
  • 45
  • 99
0
votes
1 answer

How to store and then execute linq2db query?

I'm very new to C#. In other languages I'm used to work with DB in a way "prepare, then execute statement with needed parameters", so I could pass prepared query to function and do all such things. Now I'm trying to solve this task: get almost…
Eldhenn
  • 63
  • 2
  • 6
0
votes
1 answer

Linq2DB can't translate a mapped column in Where clause

I'm working with a legacy Oracle database that has a column on a table which stores boolean values as 'Y' or 'N' characters. I have mapped/converted this column out like so: MappingSchema.Default.SetConverter
jarodsmk
  • 1,876
  • 2
  • 21
  • 40
0
votes
1 answer

Caching in Linq2DB

Does the Linq2DB ORM support query result caching - first level or second level? I noticed the namespace LinqToDB.Common.Internal.Cache, does it mean caching has to be built by the consuming application through a custom caching manager?
arung
  • 111
  • 1
  • 1
  • 7
0
votes
1 answer

It's possible to add a custom column with linq2db?

I am using linq2db with the FluentMappingBuilder to map my database, and I want to know if I can map an custom column to my class. This is my query. SELECT p.Id, p.Name, p.Price, dbo.FN_DISTANCE_HAVERSINE(a.latitude,…
Benevides
  • 25
  • 4
0
votes
0 answers

Linq2DB Create dynamic table model

Is it possible to create a table model that depends on the user input ? Globally I'll get a List containing the column names of the table that I should create in the DB. The Question is how can I manage that as I don't know how many columns I must…
CrazyNoun
  • 23
  • 5
0
votes
2 answers

Linq2DB (SQL Server): chaining Sql.Property calls dynamically

I am using the examples from this Pull Request as a reference for nested property chains. Unfortunately something like Sql.Property(x, "SomeClass.SomeProperty") doesn't work. Say I have a model, SortDescriptor (defined below), which…
Michael Rentmeister
  • 167
  • 1
  • 6
  • 24
0
votes
2 answers

Linq2db create table with DateTime2(3) fails when using in memory db and SQLiteDataProvider

I am trying to create table in memory db using Linq2Db, and SQLiteDataProvider in a netcore3.1 application. And if mapping class has a property with attribute [Column(DataType=DataType.DateTime2, Precision=3), Nullable ] it gives me the…
0
votes
1 answer

Select count with join and group by

I have linq query in my code which does not give the right output. I have two Mysql tables "classes" and "eleves" which have a 1-n relationship. This is the query: from p in db.Classes from e in db.Eleves.LeftJoin(el => el.Classe == p.IdC) group e…
Sweet MBH
  • 23
  • 9
0
votes
0 answers

How to properly use an Union with IQueryable into an one-to-one relationship with linq2db?

My regular SELECT works fine. But when I use a UNION clause, it only works if I am not using the relationship. I'm getting some exceptions depending on the way I am doing the SELECT I am using linq2db fluent mapping with SqlServer. Here are the…
Benevides
  • 25
  • 4