4

I want to be able to take a LINQ statement like this.

var User = from u in Users
           where u.UserID == 7
           select u.UserName;

And have it generate SQL like this.

SELECT UserName FROM Users WHERE Users.UserID = 7

I know LINQ TO SQL does this but I don't want all that added xml mapping and generated code. Obviously this is possible since LINQ TO SQL does it but how does it do it?

Update

Other reason why I don't want to use LINQ to SQL is because I want to use it for PostgreSQL.

4
  • Possible duplicate of stackoverflow.com/questions/550826/… Commented Oct 28, 2010 at 2:27
  • The answer uses LINQ to SQL which is not what I want. Commented Oct 28, 2010 at 2:37
  • 1
    DbLinq is an open-source LINQ provider for PostgreSQL: code.google.com/p/dblinq2007 Commented Oct 28, 2010 at 12:55
  • DbLinq looks very promising. Is it production ready? Commented Oct 28, 2010 at 13:22

4 Answers 4

2

So, you should download LinqPad:

http://www.linqpad.net/

This will give you some nice information about what LINQ is doing.

Sign up to request clarification or add additional context in comments.

Comments

1

You probably want one of the approaches suggested here- http://www.thereforesystems.com/view-query-generate-by-linq-to-sql/

But you could consider instead using Entity Framework with Postgres SQL http://www.devart.com/dotconnect/postgresql/

1 Comment

The first one uses LINQ to SQL and the second one is a product. Looking for an open source answer or some steps on how to do it.
1

Right now there doesn't seem to be an open source production ready LINQ to PostgreSQL library. So since this is a new project I'm going to use MongoDB with MongoDB-CSharp as my LINQ driver. It does everything I need it too with the added benefit of not having to worry about schemas and stored procedures.

Comments

0

Try to use Devart LinqConnect - http://www.devart.com/linqconnect/. It supports PostgreSQL and allows you to define flexible templates for sql generation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.