how to generate dbml file from Sybase database? - c#

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.

Related

Easiest way to use SQL in a C# application?

I'm making an application in C# (with Express Edition) for which I would like to add some SQL functionality so that the user can query a database. I don't care how or where I store the database. I can store it in a DataTable or a bi-dimensional array or any kind of file. But I want the user to be able to SQL-query it. Apparently this should be quite simple since the .net seems to be full of database libraries and stuff. I was thinking about downloading MySQL and see if I can connect it to my application. I guess if I want to distribute my application then the user would need to download MySQL as well, which is not a big deal but would be great if I can avoid it. Anyway, for now I would like to start working on my program ASAP, so whatever is the easiest way to do what I want, even if it's not distributable, (but if it is then that's even better), will be good. Thanks in advance.
There are embeddable databases. SQL Server Compact Edition and SQLite are common ones. You can execute queries against these just as you can MySQL or SQL Server.
SQLite (.NET)
SQL Server Compact
You can use most popular databases with .NET. SQL Server, Oracle, MySQL, etc. But you're gonna need drivers of each. So, I'd suggest using SQL Server Express Edition to you to get started.
Then you can easily use SqlConnection and SqlCommand classes to connect and execute queries.
You could use a dbml file in your project and link it to your sql database and then run a sql statement using Linq2SQL documented here
I would look at using and embedded database that you can distribute with your application. SQLite is a very good option. You can then use a free ADO.Net library like System.Data.SQLite for data access. It also provides design time support for Visual Studio.
You can use LINQ to Objects or LINQ to Datasets to run LINQ queries with no database whatsoever. You can't use a bi-dimensional array, but you can use a List<> of objects with properties as a LINQ context.
From your question it sounds like your application, like most applications, may need to store the data for later use: that's where a database will come in handy. .NET Datasets have built in support for persistence to an XML file if your data storage requirements are simple enough to use that. .NET also supports persistence for objects, but you may find that using a database is the simplest solution, especially if you require multi-user access and editing.

Connecting To SQL Database In C#

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

Which DB? Linq to SQL classes

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.

can LINQ being used with Sybase database?

Customer wants to move from SQL server to Sybase database. Don't know if LINQ can still be here? change is big?
The following article states that Sybase provide support for SQL Anywhere through the Entity Framework.

How do you use LINQ with Sqlite

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.

Categories

Resources