views:

407

answers:

3

I'm testing out DBLinq-0.18 and DBLinq from SVN Trunk with MySQL and Postgresql. I'm only using a very simple query but on both database DBLinq is not generating a Where clause. I have confirmed this by turning on statement logging on Postgresql to check exactly what request DBLinq is sending.

My Linq query is:

MyDB db = new MyDB(new NpgsqlConnection("Database=database;Host=localhost;User Id=postgres;Password=password"));

var customers = from customer in db.Customers
                where customer.CustomerUserName == "test"
                select customer;

The query works ok but the SQL generated by DBLinq is of the form:

select customerusername, customerpassword .... from public.customers

There is no Where clause which means DBLinq must be pulling the whole table down before running the Linq query.

Has anyone had any experience with DBLinq and know what I could be doing wrong?

+1  A: 

I found the problem and it's nothing to do with DBLinq.

I had been testing some stuff out from IronRuby and within that there is an assembly called Microsoft.Scripting.Core which duplicates the System.Data.Linq namespace (why it does that I don't know).

With a reference to the Microsoft.Scripting.Core assembly my test DBLinq app would compile and run fine but would have the where clause missing on the SQL. Removing the assembly reference resulted in the where clause correctly being generated.

sipwiz
A: 

I'd avoid using DBLinq for production code... many of Linq-To-SQL's features aren't implemented, and walking through the source code shows a low level of maturity... many of the methods are not implemented or marked as "unterminated".

...you've been warned!

Mark
I have been using DbLinq in a fairly demanding production environment for about 3 months now. The major issue I've had is performance. Relatively speaking it's a big hit each time DbLinq generates SQL from a lambda expression. I'm replacing it with my own Linq-to-SQL library which is incredibly basic. I only need support for very simple queries but I do need it to be fast plus I now need to use Amazon's SimpleDB so my library accommodates Linq-to-SQL and Linq-to-SimpleDB.
sipwiz
A: 

I've just set out to find something like linq to sql, but for mysql. Seems there's dblinq, nhibernate, interlinq. Could any of these do the job? I don't need any fancy interface, just write linq queries to mysql from vs.

Chababa
You should ask a separate question. As far as DbLinq goes if your queries are simple enough it should work fine. DbLinq is very heavy on CPU so if you have or a planning to use it with a production app do some thorough load testing first.
sipwiz