There are numerous libraries providing Linq capabilities to C# code interacting with a MySql database. Which one of them is the most stable and usable on Mono?
Background (mostly irrelevant): I have a simple C# (.Net 2.0) program updating values in a MySql database. It is executed nightly via a cron job and runs on a Pentium 3 450Mhz, Linux + Mono. I want to rewrite it using Linq (.Net 3.5) mostly as an exercise (I have not yet used Linq).
The only (free) linq provider for MySql is DbLinq, and I believe it is a long way from production-ready.
There is also MyDirect.Net which is commercial, but I have heard mixed reviews of it's capability.
I've read that MySql will be implementing the Linq to Entities API for the 5.3 version of the .net connector, but I don't know if there's even a timeline for that. In fact, MySql has been totally silent about Entity Framework support for months.
Addendum: The latest release of the MySql Connector/Net 6.0 has support for the EF according to the release notes. I have no idea how stable/useful this is, so I'd love to hear from anybody who have tried it.
According to the Mono roadmap I'm not sure if Linq is available for mono?
At least some of Linq might be available in the very latest release, but Linq to DB is listed for Mono 2.4 (Feb 2009)
Not sure about Mono, but I just started using LightSpeed and that supports LINQ-to-MySQL.
at this time you cannot use linq to sql, you might look into a third party linq mysql provider or linq to entities. linq to sql only works for sql server databases.
LINQ to SQL is simply a ORM layer leveraging the power of expressions to make it easy to construct queries in your code.
If you are just calling adhoc queries for your tool, there is little need to use LINQ, it just adds an extra layer of abstraction to your code.
I have tried the tutorial at http://www.primaryobjects.com/CMS/Article100.aspx. This uses dblinq/dbmetal to generate the data context class and classes for each table.
The code failed at the first attempt with an unhandled exception (MySql.Data.Types.MySqlConversionException: Unable to convert MySQL date/time value to System.DateTime"). Googling revealed this should be easily solved by appending "Allow Zero Datetime=True;" to the connection string.
Unfortionately this turned out not to solve my problem. Thinking the MySQL .Net Connector was to blame I executed the SQL generated by dblinq without the linq2sql intermediary layer using the MySQL Connector. This time no exception occured.
Tables which do not have a date column did work with DbLinq.
So, from my experiment I agree with Adam, DbLinq is a long way from production ready.
Related
Just wondering if any Firebird users can confirm that batched queries is not a supported feature in the current release (2.5) and if anyone knows if this is in the pipeline for a future version?
We use NHibernate as an ORM in our C# application and would dearly like to make use of the "Futures" feature to combine the execution of multiple queries into one request sent to the server. We've discovered that this feature isn't available as our queries "fallback" to one request per query instead of batching them.
I know Firebird has an "EXECUTE BLOCK" statement which effectively creates a virtual stored procedure but it doesn't seem possible to implement this with any of the current .NET providers for Firebird. Is anyone using Futures with Firebird? Firebird is a great database, free and can be implemented as client/server or embedded ... I mean there's not much that Firebird lacks except support for batching queries.
Any experts want to add their opinion?
Firebird itself does not support query batching. This could be simulated in the driver (this is wat the Firebird JDBC driver Jaybird does), but as far as I know the .NET provider for Firebird does not provide this feature.
Firebird 4 will introduce support for batched queries in its protocol, but drivers like the Firebird ADO.net Provider and Jaybird will need to implement support for this.
I'm learning LINQ to SQL in LINQpad and it's been great, but there's a lot of magic happening under the hood that I don't quite understand. I am connecting to an Oracle database using the optional IQ driver that can be downloaded inside of LINQpad. I have my query working and now I need to move it into a new project within Visual Studio.
Is it possible to use IQ within my solution in Visual Studio? I can't seem to find any information about using it outside of LINQpad. I've attempted to use DbLinq's DbMetal tool to generate the proper connection class but something in my schema is choking the tool in a way that it did not for IQ.
Can the generated code for LINQpad be exported in some way? The generated Oracle connection code works perfectly in LINQpad - is there a way to just reuse that generated code?
Yes, it's technically possible to use the typed DataContext that LINQPad creates within your own VS solution. You can extract it by running a query such as this:
File.Copy (GetType().BaseType.Assembly.Location, ...
As Tom suggests, you'll also need to copy the supporting files in C:\ProgramData\LINQPad\Drivers\DataContext\4.0\IQDriver. Bear in mind that LINQPad uses the DevArt Oracle dotConnect as the ADO.NET backend for Oracle, for which you'll need to buy a commercial license in order to use in your own projects.
Another issue is that there's no way to customize the typed DataContext and this could prove limiting within the context of writing a VS solution (LINQPad generates the typed DC via Reflection.Emit and so there's no source code to tweak).
If you want to access Oracle databases via LINQ in a VS project, a better option might be buy DevArt's professional edition of dotConnect for Oracle which gives you an entire stack including an integrated VS designer for writing DataContexts (so you won't need IQ). The whole experience is very much like LINQ to SQL, but for Oracle (in fact, they've mimicked the API whereever possible which eliminates the learning curve). DevArt's LINQ translation engine has improved over the years and is now close to IQ's in translation ability (and better in some ways).
Yes, you can use the IQ (IQToolkit & IQToolkit-Oracle Provider) within your projects. You can get the dlls from your LINQPad install (C:\ProgramData\LINQPad\Drivers\DataContext\4.0\IQDriver*).
You will also want to use IQToolkit CodeGen tool to create your Entities and mappings.
As you know, Linq to SQL doesn't support Oracle natively.
A previous SO poster says "As of beta version 4.35, LINQPad supports Oracle fully - you can now do "LINQ to Oracle" queries. I believe it uses the DevArt dotConnect libraries for managing this great feat." [see https://stackoverflow.com/questions/1376132/linqpad-and-oracle/6821073#6821073]
which makes me think that if you want the same functionality outside of LinqPad your going to have to get the dev art oracle connector
I have a simple app written using SQL Server, Entity Framework, C# and WCF. When I wanted to share this app with my friends, I realised they didn't use SQL Server on their machine. I could go for SQL Server Express edition, as the usage of my app is personal and non-commercial.
I found MySQL as a popular alternative to SQL Server.
1) Would I be required to update my entities when moving to MySQL?
2) Should I anticipate code changes in my BL layer due to change in entities layer? (I am wondering whether entities was built for SQL Server)
Are there any databases similar to MS Access that is lightweight compared to MySQL?
Are there any databases that need not be installed but can be copied around like MS Access?
Appreciate your response!
Sounds like you want SQLite.
SQLite is a software library that
implements a self-contained,
serverless, zero-configuration,
transactional SQL database engine.
Very easy to deploy. Also, check out System.Data.SQLite.
According to the System.Data.SQLite page ...
Supports nearly all the entity
framework functionality that Sql
Server supports, and passes 99% of the
tests in MS's EFQuerySamples demo
application.
You should be good. :)
Im not sure how your BLL looks like and i have no experience with entity framework, but ive experienced multiple times that linq-to-sql works much better with sql-server as with any other database.
So unless you have a good reason not to use sql express, i'd advice to stick to sql express.
After all, you should always install something when deploying (unless you use xml as storage, which is quite well possible with linq-to-xml).
VistaDB Express Edition is also free for non-commercial usage and integrates good into .NET and VS. afaik it also works on a single local data file thus requires no specific installation on your friends' computers.
Otherwise I recommend using PostgreSQL over MySql since it is more standards compliant and has a nicer license.
I think what you're after is just a change in providers. What you need to use MySQL is the .Net Connector which supports most everything simple. It's not very mature yet so something very complex you may have issues on, but it should do most of what you want through Entity Framework.
With Entity Framework yes you can do updates, it's LINQ-to-SQL that doesn't update against any other databases (unless you use a third party provider like DotConnect)
SQLite is one alternative, but since multiple threads against it can cause major issues with it's operation, so if you need a major data store I'd go SQLExpress or MySQL.
Yes, you could use MySql with EF but I don't know if it would require changes.... I wouldn't be surprised if it does though. At the very least your physical DB would have to be ported / converted to MySql and that will take time.
I would assume that if you need to install a DB on your friends Pc's why not stick with SQL Express since you already developed in SQL Server on your box. Should be less issues with this than migrating to MySql.
I'd also vote for VistaDB 3 as it's so easy to deploy.
Im working on an application that needs to talk to a database. The application is written in C#. Im quite taken by LINQ and auto generating classes to represent the database and its tables, so first I considered using SQL as .NET only comes with support for LINQ to SQL. Right now Im leaning more to MySQL mainly because scaling the SQL server might get pricey and because the people within my company are more familiar with MySQL, including me. This is where dbLinq comes in. From what I have read dbLinq works fine for simple queries but might break down on more complicated ones. Could you share your experiences in using dbLinq? Should dbLinq still be regarded as experimental or could I expect to use it without a lot of problems?
Thanks, Bas
Edit:
I read that DbLinq is not able to handle more than one foreign key, can anyone comment on whether this is still the case?
I don't know much about dbsql but check out Entity Framework. It allows you do Linq and can be used with MySQL. Check out this SO question for more info on LinqToEntityFramework for MySQL Using MySQL with Entity Framework
I used EntityFramework to connect to MySQL db in my last project. It is gives some minor issues but reduces amount of effort required to code. I am super impressed with it. I had to do Paging and Filtering in that application. Because of EF this was a piece of cake.
This application had very less data (fraction of millions rows). I would like to know how Entity Framework will do in Applications which has large data.
Would someone explain how to get LINQ working with Sqlite.
Here you have an SQL Linq provider for SQLite, and some other DBs
Joe Albahari's LINQPad now supports Sqlite: http://www.linqpad.net/Beta.aspx. The one LINQ tool to rule them all.
The link provided by CMS doesn't work anymore. I have used this one as it now seems to be baked into their SQL lite ADO .NET provider.
Unfortunately they still don't support the designer mode of VS for creating classes :(
Also be aware that SQL Server compact doesn't support the design mode for LINQ classes! However if you want to use the entity framework the designer does work for SQL lite and SQL Server compact :)
Yup there is a SqlLite Linq Provider as mentioned by CMS
Check out SQL server compact and it works well with Linq
There is another thread on SO which you should check
I would like to add that you can use Linq to Sql with SqlLite with a couple of stipulations:
You cannot use the Linq to Sql designer which means you have to hand roll your classes.
You have to be careful not to do certain operation which will result in Sql code which is not supported by SqlLite.
For example, you cannot use FirstOrDefault() in any of your Linq queries because it will result in something like:
select top 1 * from table where ...
Since SqlLite doesn't support the "top 1" syntax, you will gt a runtime Sql error.
Other than that, I have been using Linq to Sql with SqlLite with great success for basic CRUD operations.
You can use this: http://code.google.com/p/dblinq2007.
Although it looks like the project is still in Alpha stage, IMO it is actually very stable now. Of course if you have a huge project, it is better to consider using something else like MySQL or SQL Compact. I don't like SQL Server, because it is too bloated, and offers not many more functionalities over SQL Compact or MySQL
Check this provider:
SqlLite Linq Provider
Also you can consider using SQL Compact which has very good LINQ-to-SQL support.
On this time there is NO good tools to do this!
LINQ providers for SQLite all is in alpha stage (for example:dblinq2007). And it is very big risk to use it in commercial purpose! So maybe in future...
If you want ot use ADO.NET there is good ove: phxsoftware.