Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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


Ïà¹ØÎĵµ£º

mysqlÊý¾Ý¿âµÄµ¼Èëµ¼³ö

Ò»¡¢MYSQLµÄµ¼³ö
½øÈëmysql°²×°Ä¿Â¼£¬½øÈëbin
ÔÚÃüÁîÐÐģʽÏ´òÈ룺
 ³ÌÐò´úÂë
mysqldump -u root -p hibernate > c:/hibernate.sql
ÆäÖÐ-u ±íʾÓû§
    -p±íʾÓû§ÐèÒªÈÏÖ¤
    hibernate±íʾҪµ¼³öµÄÊý¾Ý¿â
    > c:/hibernate ±íʾ½«Ê ......

ÀûÓÃBind DLZ MySQL ¹¹½¨ÖÇÄÜDNS

±¾ÎÄÀ´×Ô: ITÔËάר¼ÒÍø ×÷Õß: NetSeek ÈÕÆÚ: 2009-3-8 19:52 ÔĶÁ: 742 ÈË ´òÓ¡ ÊÕ²Ø DNS, Bind, DLZ, ÖÇÄÜ, MySQL ×÷Õß:NetSeek  http://www.linuxtone.org
ÈÕÆÚ:2009-3-7 gmail:cnseek@gmail.com
ÍƼöÏÂÔØPDF°æ£¨·½±ã²éÔÄ):http://www.linuxtone.org/project/cdn/bind-dlz-view.pdf
¡¾Ìâ ¸Ù¡ ......

mysql »ù±¾ÃüÁî

µÚÒ»ÕС¢mysql·þÎñµÄÆô¶¯ºÍÍ£Ö¹
net stop mysql
net start mysql
µÚ¶þÕС¢µÇ½mysql
Óï·¨ÈçÏ£º mysql -uÓû§Ãû -pÓû§ÃÜÂë
¼üÈëÃüÁîmysql -uroot -p£¬ »Ø³µºóÌáʾÄãÊäÈëÃÜÂ룬ÊäÈë12345£¬È»ºó»Ø³µ¼´¿É½øÈëµ½mysqlÖÐÁË£¬mysqlµÄÌáʾ·ûÊÇ£º
mysql>
×¢Ò⣬Èç¹ûÊÇÁ¬½Óµ½ÁíÍâµÄ»úÆ÷ÉÏ£¬ÔòÐèÒª¼ÓÈëÒ»¸ö²ÎÊý-h»ú ......

MysqlËø»úÖÆ

mysqlËø»úÖÆ
mysqlÖÐ¶Ô±í¼¶µÄ´æ´¢ÒýÇæÀ´ËµÊÇÊÍ·ÅËÀËøµÄ£¬±ÜÃâËÀËø¿ÉÒÔÕâÑù×öµ½:ÔÚÈκβéѯ֮ǰÏÈÇëÇóËø£¬²¢ÇÒ°´ÕÕÇëÇóµÄ˳ÐòËø±í¡£
MysqlÖÐÓÃÓÚwrite(д)µÄ±íËøµÄʵÏÖ»úÖÆÈçÏ£º
Èç¹û±íûÓмÓËø£¬ÄÇô¾Í¼ÓÒ»¸öдËø¡£·ñÔòµÄ»°£¬½«ÇëÇó·Åµ½Ð´Ëø¶ÓÁÐÖС£
mysqlÖÐÓÃÓÚread(¶Á)µÄ±íËøµÄʵÏÖ»úÖÆÈçÏ£º
Èç¹û±íûÓмÓËø£¬ÄÇô ......

MySQLÐÐËøÉîÈëÑо¿

      ×öÏîĿʱÓÉÓÚÒµÎñÂß¼­µÄÐèÒª£¬±ØÐë¶ÔÊý¾Ý±íµÄÒ»Ðлò¶àÐмÓÈëÐÐËø£¬¾Ù¸ö×î¼òµ¥µÄÀý×Ó£¬Í¼Êé½èÔÄϵͳ¡£¼ÙÉè id=1 µÄÕâ±¾Êé¿â´æΪ 1 £¬µ«ÊÇÓÐ 2 ¸öÈËͬʱÀ´½èÕâ±¾Ê飬´Ë´¦µÄÂß¼­Îª :
Select restnum from book where id =1 ;
-- Èç¹û restnum ´óÓÚ 0 £¬Ö´ÐÐ update
Update boo ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ