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
1 answer

linq2db - exception is thrown when using Lead function

We are using .NET Core 3.1, Microsoft.EntityFrameworkCore 3.1.9, Npgsql 4.1.9, LinqKit.Microsoft.EntityFrameworkCore 3.2.3 and linq2db.EntityFrameworkCore 3.7.0. We have the following 2 scaffolded classes: [Table("testrunconfig", Schema =…
Sam Carlson
  • 1,891
  • 1
  • 17
  • 44
1
vote
0 answers

Linq2db QueryExpressionMethod is throwing value cannot be null, but works with Association keys

I'm trying to convert the Linq2db Association based on keys, to Association method (to clean up other parts of code): This code works: [Association( CanBeNull = true, ThisKey = nameof( AccountId ), OtherKey = nameof( Common.Account.AccountId )…
galaxyfreak
  • 69
  • 1
  • 5
1
vote
1 answer

Project on update/create (set values from another object en masse) in LINQ2DB?

When using LINQ2DB for my application I tried to use entity-DTO mapping using Expression> and vice versa like described here: https://github.com/linq2db/linq2db/issues/1283#issuecomment-413509043 This works great for projecting…
Kerbiter
  • 13
  • 3
1
vote
0 answers

LinqToDB DataConnection not disposed upon exiting using block

This issue has been perplexing me for quite a while. I'm trying to dispose of a connection to a database, but it keeps leaking no matter how I try to dispose of it. Worse yet, it's supposed to dispose automatically. Long story short, I have a…
Johnny Cache
  • 1,033
  • 7
  • 12
1
vote
0 answers

How can I compose the result object of a linq to sql query to maximize code reuse?

Setup I am using a linq-to-sql query (using Linq2db) to perform a search. Depending on which part of the application the user runs this search from, the result will have certain additional fields populated. The result object thus contains some…
Daniel
  • 1,695
  • 15
  • 33
1
vote
1 answer

Linq2db.EntityFramework dependency is giving error

var query = from s in context.AssetStatusRecord.ToLinqToDB() // switch LINQ Provider where s.Speed != 0 && s.CreationUtcTime <= endTime && s.CreationUtcTime >= startTime && s.AssetId == assetId orderby s.CreationUtcTime select new { …
Shalabh Mishra
  • 44
  • 1
  • 2
  • 11
1
vote
1 answer

linq2db exception: "Configuration string is not provided". I don't have a web/app.config, but even if I give the string explicitly, same exception

I'm working on a training project developing a DAL for Northwind with Entity Framework and another DAL with linq2db in the same project. I keep getting the error when I run a test which uses linq2db: LinqToDB.LinqToDBException : Configuration…
1
vote
1 answer

IUpdatable and IValueInsertable from optional values?

Is it possible to build something like this in Linq2DB? Currently I have a problem that ITable is not assignable to either IUpdatable or IValueInsertable. Or maybe what I'm trying to achieve is not a good practice? var optional1 =…
mihails.kuzmins
  • 1,140
  • 1
  • 11
  • 19
1
vote
1 answer

How to access an Oracle linked table in Linq2db?

I have a linked table I access like this: SELECT Id, Name FROM MySchema.Sectors@STATS How do I define that in Linq2db? I tried: [Table(Schema = "MySchema", Name = "SECTORS@STATS")] public partial class Sector but when I try to load it, I…
Robin Bennett
  • 3,192
  • 1
  • 8
  • 18
1
vote
0 answers

Why would Linq2Db not be able to 'see' an Oracle table?

I have a new account that has read-only access to a new table that our database guy has created. The account can query the table in 'Oracle Sql Developer' but is not the owner of the table (so it doesn't appear in the 'connections' tree) and I think…
Robin Bennett
  • 3,192
  • 1
  • 8
  • 18
1
vote
1 answer

Four nested associations using LoadWith and ThenLoad in LinqToDb

I have a question that is about using LoadWith and ThenLoad. I need to get the fourth association. I can get the third association. For instance, Post -> CreatedUser -> UserDetail, but I can not the fourth association. I can not get UserDetail for…
Ismail Dogan
  • 295
  • 2
  • 20
1
vote
1 answer

Linq2DB - Generate Data Model for a given schema only

Trying to Linq2DB for the first time - I have DB with multiple different schemas. Only a selected schema needs to be ORMed. Currently, it is generating multiple classes, some of which are duplicates. I have same tables across schemas. so, how do I…
FSharp
  • 11
  • 2
1
vote
0 answers

Column mapper in linq2db is not working the same as in EF Column mapping

This entity/Poco was working fine with EF: [Column(Name="myFieldNameOnDB")] public string MyPropNameOnClass{ get; set; } After replacing EF in the entire solution with Linq2DB, it is working where poco class properties are the same as column/field…
Bashar Abu Shamaa
  • 1,998
  • 2
  • 21
  • 36
1
vote
1 answer

Linq left join on string values fetching incorrect data from Oracle database

Working with a left join on an Oracle DB is causing some interesting data issues to be returned when using Linq2Db as the mapping layer. SELECT * FROM REBATE_HISTORY frh LEFT JOIN PAYMENT fp ON frh.TRANSACTION_REFERENCE_NUMBER =…
Conway Stern
  • 152
  • 2
  • 10
1
vote
0 answers

linq2db bulkcopyasync without error but no data inserted in the database

I am using linq2db .NET Core library to bulk insert a collection. This code can be executed without error but there is no data in the database. There are 2000 person object in persons list object. Person object has already identity in it. using…
Steve
  • 2,963
  • 15
  • 61
  • 133