I am planning to store XML in the database and looking for an ORM that can easily query values in the database. I will be using SQL Server 2008 or MySQL depending on the XML support. Can you give your thoughts or advice on which tool is best for this.
Linq to SQL can do so... see this
Related
We have a application that is making requests to a MSSQL DB via Entity Framework. One column in one table is a serialized C# class, stored in XML format. We would like to perform simple XPath queries against this data from C#. Currently we simply load the dataset, parse the XML via linq-to-XML then query the structure. This is of course the absolute worst way to solve this problem, so I'm looking for alternatives.
MS SQL 2008 can query XML data, so how do I do that through EF?
You can use a stored procedure. Or you can run dynamic SQL using ObjectQuery. Other than that, I don't know of any way to use the XML features of SQL Server through EF.
I'm pretty familiar with SQL syntax (via MySQL) and am just getting my feet wet with C# and SQL server.
I currently have a .sdf database on my C:\ drive and want to connect to it in C#.
I added the database as a data source and now need help figuring out how to get data from the database in my C# application.
I just want to be able to set an object to the data in my SQL database so I can manipulate it using C#.
Thanks in advance for replies.
A *.sdf file means you're using Compact Edition. That's a little different - more analogous to an Sqlite or Access style database than MySql or a full Sql Server.
As to the rest of it, there are as nearly many ways to do that as there are programmers. However, most of them at some level will involve the System.Data.SqlCe namespace, which is where the Sql Server Compact Edition data provider lives. If you decide to move up to a full Sql Server edition, like Sql Server Express (still free), you would instead use the System.Data.SqlClient namespace.
Additionally, I want to focus on your specific statement:
I just want to be able to set an object to the data in my SQL database so I can manipulate it using C#.
That sounds like you're really just interested in an ORM (Object/Relational Mapper). I can't comment on how well specific ORMs work with Sql Server Compact Edition, but now that you know what you're looking for you should be able to conduct your own search.
There's many ways to do this, but first off, do mean ".mdf" instead of ".sdf"?
An .sdf file is a database from SQL Server Compact Edition (CE).
Try this: http://www.lfsforum.net/showthread.php?t=52392
-Krip
I want to develop a multiuser supporting accounting management application in C#.
I want to use Linq To SQL classes. LINQ to SQL only supports SQL Server/Compact. However is it possible the SQLite people have written their own LINQ provider given the name of the assembly.
I have to use DBMS that is FREE. Which DBMS do you suggest to me?
LIN2SQL = SQL Server. Second class badly written O/R mapper compared to the real contendors (like NHibernate).
LINQ2SQL != LINQ. LINQ is the query integration into the langauge, and supported by pretty much a lot of O/R mappers out there, and some databases.
I have to use Db that is FREE.
Free like for free? What is against sql server? Express edition - 0 USD. And the 4gb "database size limit" does not stop you from writing accounting systems. THat is a LOT of space for accounting data. For many years of accounting data.
If you want to use Linq-to-SQL (which I think is an excellent choice) you have to use some variant of MSSQL. Both Sql Server Compact and Sql Server Express are free to use. If you have a multiuser scenario you will have to go for Sql Server Express as Sql Server Compact doesn't allow multiple simultaneous access.
There are various experimental linq to sql and linq to entity framework providers for other databases(like mysql and postgres) - in my experience they are so immature it is not worth using for anything serious.
For now, I'd suggest you'd look for something else if you cannot use SQL server.
Try the following link:
http://sqlite.phxsoftware.com/
Note that Linq2SQL is not compatible with SQLite, however the link points to an Entity Framework provider for SQLite. EF is kind of like Linq2SQL on steroids. SQLite is very lightweight, so the EF implementation above should work nicely for your needs.
I think we may have trouble with our existing project. For some reasons we have to switch from SQL Server to Sybase SQL Anywhere 11. now we trying to find a way continue use our existing LINQ code.
We wish we can still use L2S? If cannot, we wish we can use L2E, then we have to change to ADO.
how to generate dbml file from Sybase Anywhere 11? after that can we use sqlmetal to generate .cs files?
Linq to SQL only supports MS SQL Server. You might consider switching to Entity Framework if this is an option and if there is a provider fro Sybase SQL Anyware.
As far as I know there are also no plans to extend the Linq to SQL support to other databases, especially as MS pushes EF as the future database technology.
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.