How to use MySql via Linq to SQL
The vs2008 and vs2010 don't support the generation LINQ to SQL business objects from a MySQL database, if you drop a MySql table to a Linq to Sql Class, it will popup a "The selected object(s) use an unsupported data provider" error.
Generation tool DBLinq
DbLinq is a LINQ to SQL data context provider and allows you to create LINQ to SQL business objects from a MySQL database and perform LINQ queries directly against MySQL tables. Utilizing LINQ, it functions in the same way as a typical SQL Server data layer.
a) Download DBLinq from: http://code.google.com/p/dblinq2007/downloads/list
b) Run the LINQ to SQL generation tool DbMetal.exe as follows:
DbMetal.exe -provider=MySql -database:MyDatebase -server:you host computer -user:mysql user -password:you pwd -namespace:mysqllinq -code:mysqllinq.cs -sprocs
Modify the generated file
The generated file can't be use in project right now, we must take some modification on it.
a) Delect all code with #if !MONO_STRICT(take MONO_STRICT as True is ok).
b) Delete the constructors from the DataContext class and add the following constructor:
public MyDBDataContext()
: base(new MySqlConnection(ConfigurationManager.ConnectionStrings["MyDb"].ConnectionString))
{
OnCreated();
}
c) For "Incorrect AutoSync specification for member" error, we should set AutoSync of pk field as AutoSync.OnInsert, the full configuration for pk field:
[Column(Storage = "_userID", Name = "userId", DbType = "int", IsPrimaryKey = true, AutoSync = AutoSync.OnInsert, CanBeNull = false)]
As the .NET compiler will convert the code into a SQL Server syntax statement, run this code under MySql will throw error(Like this issue:http://lists.mysql.com/mysql/215385
相关文档:
一、表单提交乱码解决方法
表单中含有中文提交乱码,对于字母和数字则不会乱码,我选用的字符集utf-8(以下同)。
1、在apache-tomcat-6.0.18\webapps\examples\WEB-INF\classes\filters目录下找到文件SetCharacterEncodingFilter.java 和RequestDumperFilter.java文件,并将其复制到项目src ......
http://incubator.apache.org/cassandra/
http://zh.wikipedia.org/wiki/Cassandra
Apache Cassandra是一套开源分布式数据库管理系统。它最初由Facebook开发,用于储存特别大的数据。
主要特性:
分布式
基于column的结构化
高伸展性
Cassandra的主要特点就是它不是一个数据库,而是由一堆数据库节点共同构成的一 ......
在MySQL中,对于索引的使用并是一直都采用正确的决定。
简单表的示例:
create TABLE `r2` (
ID` int(11) DEFAULT NULL,
ID1` int(11) DEFAULT NULL,
CNAME` varchar(32) DEFAULT NULL,
KEY `ID1` (`ID1`)
) ENGINE=MyISAM DEFAULT charSET=latin1
select count(*) from r2;
......
Accessing Distributed Data with the Federated Storage Engine
http://dev.mysql.com/tech-resources/articles/mysql-federated-storage.html
Federated存储引擎可以使几台数据库逻辑上组成一个数据库,其作用相当于Oracle的数据库链接,通俗地说,即在本地建立远程的数据库表的引用。
Mysql需要5.0以上
(1)查看是 ......
第一招、mysql服务的启动和停止
net stop mysql
net start mysql
第二招、登陆mysql
语法如下: mysql -u用户名 -p用户密码
键入命令mysql -uroot -p, 回车后提示你输入密码,输入12345,然后回车即可进入到mysql中了,mysql的提示符是:
mysql>
注意,如果是连接到另外的机器上,则需要加入一个参数-h机 ......