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
2
votes
2 answers

Difference in represtantion of floating point number in double type property (class) and in double type field (SQL query)

I have a class representing specific database table. Some the properties in this class as well as some of the fields in database table are type double. Here, in the class, you see some properties have 1 significant digit eg. T12, T13, T18, T19 (0.8,…
yarecky
  • 97
  • 8
2
votes
0 answers

Merge local entities into a table skipping primary keys (linq2db)

I want to merge a list of local entities into a table (if they don't exist already) using linq2db. I try to do the following: var recordsConvertedToOrders = reportRecords.Select(i => { // some predefined conversion var order =…
Ivan Akcheurov
  • 2,173
  • 19
  • 15
2
votes
1 answer

Read-only column with Linq2DB

In my SQL Server table, I have a computed column. So for that column, I want to have only reading statements (like 'select') and no writing statements (like 'update') in generated code by Linq2DB. What is the easiest way to do it? I don't want to…
2
votes
1 answer

Linq2DB adding unnecessary statements to query

I am trying to generate a query that gets the number of entries with dates that occur within each given month. The SQL form of the query I wish to generate goes like this: SELECT DatePart(Year, [t1].[StartTime]) as Year, DatePart(Month,…
Michael Kossin
  • 342
  • 3
  • 14
2
votes
1 answer

Grouping by just the date in Linq2DB

I am trying to generate an sql query using Linq2Db in C#. The query I want to generate is this: SELECT cast([t1].[StartTime] as date) as [StartTime1], Count(*) as [WebpageVisits], Sum([t1].[PageCount]) as [SumOfViewsOfPages] …
Michael Kossin
  • 342
  • 3
  • 14
2
votes
1 answer

linq2db find string in varchar field

When I make a complex query and try to filter out the data on a varchar type column, the provider converting in sql code the required variable is not in the "where" block, and declares a variable of type NVarchar and assigns it a value. And block…
Redliru
  • 21
  • 2
2
votes
1 answer

How to call a PL/SQL function returning an OracleRefCursor with Linq2DB?

I would like to call a PL/SQL function that returns a SYS_REFCURSOR. One of the ways I have tried looks like this: var userIdParameter = DataParameter.Decimal("userId", user.Id); var returnValue = new DataParameter { Direction =…
CodeFox
  • 3,321
  • 1
  • 29
  • 41
2
votes
1 answer

Insert into #tmp table using lin2db

I have a set of tables I need to run some queries against. 2-3 tables used are the same so makes sense to create a tmp table (limited access to the server so no views, stored proc solutions please). Any idea how to achieve that using linq2db? TIA
2
votes
1 answer

How can I use association in linq2db

I try to use linq2db with firebird sql server. I have two tables, which have releation. [Table("REQUESTS")] public partial class Request { [Column("ID")] [PrimaryKey] public int Id { get; set; } …
2
votes
2 answers

Type Initializer Error Thrown by linq2db InformixDataProvider when run in Web Application but not Console

I am trying to use the linq2db library (thanks by the way!) to retrieve records from an Informix database. I followed the steps from the documentation and was able to successfully get records from an ASP.NET console applicaiton using the Visual…
robnardo
  • 921
  • 11
  • 27
2
votes
3 answers

LinqToDB: How to change connection string, or set it without using project's configuration

https://github.com/linq2db/linq2db I need to use different connection strings and can't find how to make it.
Anton Pavelyev
  • 469
  • 4
  • 20
1
vote
1 answer

.Net linq2db, fluentMappingBuilder, table name not apply for query

I'm diving into a little project with linq2db. I've set up models, a connection, and a simple query. But here's the thing: every time I run the query, linq2db uses the table name from the entity model, not the name from fluentmapper. Am I missing…
Overcode
  • 140
  • 6
1
vote
1 answer

How do I write a LINQ query for a list of users with their first article?

How do I write a LINQ query that would translate to the following SQL? SELECT u.id, u.username, a.id, MIN(a.created_at) AS firstArticle FROM users u INNER JOIN editorial_articles a ON a.user_id = u.id GROUP BY u.id ORDER BY u.id, a.created_at,…
glen-84
  • 1,778
  • 2
  • 18
  • 30
1
vote
1 answer

Linq2DB doesn't translate a computation expression inside select statement

I'm using Linq2DB over EF Core database context, which is connected to the PostgreSQL 15, and I want to generate a query that will have complex calculations inside the SELECT statement. Environment Packages: Linq2DB.EntityFrameworkCore…
Vlad Kiselev
  • 339
  • 2
  • 9
1
vote
0 answers

linq2db logging to file using Karambolo

We are using .NET Core 3.1, Microsoft.EntityFrameworkCore 3.1.9, Npgsql 4.1.9, Karambolo.Extensions.Logging.File 3.3.1 and linq2db.EntityFrameworkCore 3.7.0. We have the following Karambolo configuration in appsettings.json: { "Logging": { …
Sam Carlson
  • 1,891
  • 1
  • 17
  • 44
1 2
3
12 13