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

Linq2Db using a Column in an Update Statement

I want to recreate the following SQL Update Command in LINQ to DB (Linq2DB). UPDATE MyTable SET TextColumn = CONCAT(TextColumn, char(13), char(10), 'New Text') WHERE TextColum IS NOT NULL I don't know how to implement this with Linq2Db because I…
SuperGURU
  • 25
  • 5
0
votes
0 answers

How to create a strong typed sql statement returning multiple result sets

Currently I am using a stored procedure returning multiple result sets. I set up a test and found that the result of the stored procedure can efficiently be read by using the "ExecuteReader" method of the DataConnection class and then Executing or…
Williwyg
  • 651
  • 5
  • 3
0
votes
1 answer

How to update a field by itself in linq2db

I mean, how can I translate the query update myTable set myField1 = myField1 + 1 where myField2 = 'xyz' Thank you
fedrok
  • 1
  • 2
0
votes
0 answers

LinqToDB 'Configuration string is not provided.'

I have to use for the first time the LinqToDB library, so I'm reading their step by step: https://linq2db.github.io/articles/get-started/full-dotnet/existing-db.html Which basically is: 1-Create a new Project (Done, console one ) …
0
votes
1 answer

Linq2Db: How to include navigation properties on (bulk-)insert

I am trying to use the bulk insert feature. My model looks like this: public class Stockprice { [Key] public int Id { get; set; } [Required] [LinqToDB.Mapping.Association(ThisKey = "StockId", OtherKey = "Id")] public Stock…
tailoxyn
  • 120
  • 9
0
votes
1 answer

Convert SQL query to Linq2db

Some one help me to convert SQL query to linq2db join query. Below is my query. var query = from a in _accountRepository.Table join b in _documentRepository.Table on a.ID equals b.AccountID join c in…
0
votes
0 answers

Linq2DB: Bulk copy failing for float type column in MS Sql server

I am trying to perform bulk copy for into a table that has few fields that are of type "float" in MS SQL Server. I noticed that after bulk copy completed, all these "Float" fields had value of "NULL". These fields allowed null value so these NULLs…
ByteBlocks
  • 607
  • 3
  • 9
  • 24
0
votes
1 answer

LinqToDB Exception cannot be converted to SQL

Hello I have an issue with this query var queryGrouped = queryFiltered .GroupBy(c => new { c.Id, c.TableOneId, c.TableOneName, c.TableTwoId, c.TableTwoName, c.TableTwoCode, c.TableThreeId, c.TableThreeName, c.Description,…
0
votes
1 answer

Linq2DB unable to connect to Postgres database using T4

I am trying to connect to my Postgres database in my T4 file using the following code: <#@ template language="C#" debug="True" hostSpecific="True" #> <#@ output extension=".cs"#> <#@ include…
gilesrpa
  • 969
  • 1
  • 12
  • 35
0
votes
1 answer

How to use linq2db to insert sql geography?

It is simple really: var a = SqlGeography.STGeomFromText(new SqlChars("POINT(-122.34900 47.65100)"), 4326);` and then insert await _geoDb.Table.Value(x => x.Geom, a) // Geom is of type SqlGeography This is giving me…
pregmatch
  • 2,629
  • 6
  • 31
  • 68
0
votes
1 answer

linqtodb use connection.BeginTransactionAsync inside asp.net core

I'm using linqtodb with great success inside a asp.net 6.0 api. But now i'm at a point where it looks like i need to use transactions and it looks like i'm misunderstanding a few things there. i'm getting the _connection object as an injected object…
fops
  • 384
  • 1
  • 13
0
votes
2 answers

exclude a list from another list in linq (linq2db)

I am doing two fetches from database by linq2db. I have two list TaskDone and TaskNotAccomplished. I want to have the rows which are not in TaskDone List taskDone = from t in db.tblTasks join a in db.tblTaskResult on t.TaskId equals a.TaskId …
nnmmss
  • 2,850
  • 7
  • 39
  • 67
0
votes
1 answer

How can I find the ID of a new object created using the Oracle sequence NextVal method using Linq2DB?

We are using Linq2DB to read and write to an Oracle table, with an Oracle sequence to track the next value for the primary key. I've worked out that I add a SequenceName attribute to the ID property, and Linq2DB calls MY_SEQ.NextVal: public class…
Robin Bennett
  • 3,192
  • 1
  • 8
  • 18
0
votes
0 answers

Linq2db.EntityFrameworkCore against Oracle

I don't understand why linq2db is not generating the correct SQL string for this query against Oracle, and it is working perfectly against SQLServer. string idUser="U1"; await context.Users.ToLinqToDbTable().Where(u=>u.IdUser ==…
dave
  • 2,291
  • 3
  • 19
  • 25
0
votes
1 answer

How to sort a child list in Linq2DB?

I have a table where each row owns a set of rows from another table, using LinqToDB.Mapping classes. [Table(Name = "SECTORS")] public partial class Sector { [Column(Name="ID"), NotNull, PrimaryKey] public int Id { get; set; } …
Robin Bennett
  • 3,192
  • 1
  • 8
  • 18