Alternatives for Sqlinq to create sql queries from linq

Sqlinq is an open source project for creating sql queries from linq. I use it with Dapper , but unfortunately it does not support JOIN.

Are there other libraries that do the same and support JOIN?

If not, what could be the solution to avoid querying the sql query?

+8
tsql linq dapper sqlinq
source share
7 answers

What about the built-in linq that comes with .NET?

http://msdn.microsoft.com/en-us/library/bb397927.aspx

+1
source share

I think you will want to rethink what technologies you want to use and why. You wrote:

is there any way to convert linq to sql query

The answer to this question is yes, and it is called ORM . many libraries to choose from.

Dapper is a micro-ORM. And although this is great, and I personally use it a lot, it seems that this is the wrong tool for your work. It does not write sql queries for you.

But other solutions. For example, microsoft provides Linq to SQL and Entity Framework as out-of-the-box solutions. You can check them out.

0
source share

Relinq has a Reqlinq.SqlBackend that you could adapt to support Dapper, I think I'm trying to work myself, but I don't have much time to work on it.

https://github.com/re-motion/Relinq

https://github.com/re-motion/Relinq-SqlBackend

0
source share

Linqer is a SQL-LINQ conversion tool: http://www.sqltolinq.com/

0
source share

When you say you don’t want to β€œhard code SQL”, is it a SQL problem or hardcoding? Since SQL is fabulous, expressive, powerful and, in any case, the language of relational databases, I am sure that this is hard coding that listens to you. So QueryFirst. Your sql coexists in your application with the same status as the host language: syntax validated as you type, directly executed in place. Each time you save your .sql, QueryFirst will regenerate its C # shell: repo, its interface and POCO for the results. Your queries are constantly tested from dev to deployment. Theoretically, there are no runtime errors from accessing data.

Download here

A small blog for discussion and comments here

Disclaimer: I wrote QueryFirst

0
source share

I use SqlLinq for queries in Dapper and find that they come with another adapter called SQLinq.Dynamic.DynamicSQLinq . There is not much information about this, but this example will help. It's not great, but at least it's something.

 new DynamicSQLinq("TBL_PRODUCT") .Join("TBL_PRODUCTTYPE", "TBL_PRODUCTTYPE.ID = TBL_PRODUCT.ID_PRODUCTTYPE") .Where("TBL_PRODUCT.ID = @0", 254) .ToSQL(); 
0
source share

You might have to take a look at this Github: https://github.com/andygjp/ExpressionToSql

Using this library, you can write queries as follows:

 var query = Sql .Select((Address x) => new { x.Id, x.Postcode }) .Where(x => x.Id > 10 && x.Postcode != postcode); 

Which will produce a request like this:

 SELECT a.[Id], a.[Postcode] FROM [dbo].[Address] AS a WHERE a.[Id] > 10 AND a.[Postcode] <> @postcode 
0
source share

All Articles