N ²ãÓ¦ÓóÌÐòÖеÄÊý¾Ý¼ìË÷ºÍ CUD ²Ù×÷ (LINQ to SQL)
http://msdn.microsoft.com/zh-cn/library/bb546187.aspx
http://www.cnblogs.com/kirinboy/archive/2010/01/20/linq-to-sql-update-1.html
¡¾ÒýÎÄ¡¿
ÔÚѧϰLINQʱ£¬ÎÒ¼¸ºõ±»Ò»¸öÀ§ÄÑËù»÷µ¹£¬Õâ¾ÍÊÇÄã´Ó±êÌâÖп´µ½µÄ¸üÐÂÊý¾Ý¿âµÄ²Ù×÷¡£ÏÂÃæÎÒ¾ÍÒ»²½²½´øÄã×ßÈëÕâÄà̶£¬Çë×¼±¸ºÃשͷºÍ¿ÚË®£¬Follow me¡£
´Ó×î¼òµ¥µÄÇé¿öÈëÊÖ
ÎÒÃÇÒÔNorthwindÊý¾Ý¿âΪÀý£¬µ±ÐèÒªÐÞ¸ÄÒ»¸ö²úÆ·µÄProductNameʱ£¬¿ÉÒÔÔÚ¿Í»§¶ËÖ±½ÓдÏÂÕâÑùµÄ´úÂ룺
// List 0
NorthwindDataContext db = new NorthwindDataContext();
Product product = db.Products.Single(p => p.ProductID == 1);
product.ProductName = "Chai Changed";
db.SubmitChanges();
²âÊÔһϣ¬¸üгɹ¦¡£²»¹ýÎÒÏàÐÅ£¬ÔÚ¸÷λµÄÏîÄ¿Öв»»á³öÏÖÕâÑùµÄ´úÂ룬ÒòΪËü¼òֱû·¨¸´Ó᣺ðɣ¬ÈÃÎÒÃǶÔÆä½øÐÐÖع¹£¬ÌáÈ¡ÖÁÒ»¸ö·½·¨ÖС£²ÎÊýÓ¦¸ÃÊÇʲôÄØ£¿ÊÇеIJúÆ·Ãû³Æ£¬ÒÔ¼°´ý¸üеIJúÆ·ID¡£àÅ£¬ºÃÏñÊÇÕâÑùµÄ¡£
public void UpdateProduct(int id, string productName)
{
NorthwindDataContext db = new NorthwindDataContext();
Product product = db.Products.Single(p => p.ProductID == id);
product.ProductName = productName;
db.SubmitChanges();
}
ÔÚʵ¼ÊµÄÏîÄ¿ÖУ¬ÎÒÃDz»¿ÉÄܽö½öÖ»Ð޸IJúÆ·Ãû³Æ¡£ProductµÄÆäËû×Ö¶ÎͬÑùÒ²ÊÇÐ޸ĵĶÔÏó¡£ÄÇôUpdateProduct·½·¨µÄÇ©Ãû½«±ä³ÉÈçϵÄÐÎʽ£º
public void UpdateProduct(int id,
string productName,
int suplierId,
int categoryId,
string quantityPerUnit,
decimal unitPrice,
short unitsInStock,
short unitsOnOrder,
short reorderLevel)
µ±È»ÕâÖ»ÊǼòµ¥µÄÊý¾Ý¿â£¬ÔÚʵ¼ÊÏîÄ¿ÖУ¬¶þÊ®¡¢ÈýÊ®ÉõÖÁÉÏ°Ù¸ö×ֶεÄÇé¿öÒ²²»ÉÙ¼û¡£ËÄÜÈÌÊÜÕâÑùµÄ·½·¨ÄØ£¿ÕâÑùд£¬»¹ÒªProduct¶ÔÏó¸ÉʲôÄØ£¿
¶Ô°¡£¬°ÑProduct×÷Ϊ·½·¨µÄ²ÎÊý£¬°ÑÄÕÈ˵ĸ³Öµ²Ù×÷Å׸ø¿Í»§´úÂë°É¡£Í¬Ê±£¬ÎÒÃǽ«»ñÈ¡ProductʵÀýµÄ´úÂëÌáÈ¡³öÀ´£¬ÐγÉGetProduct·½·¨£¬²¢ÇÒ½«ÓëÊý¾Ý¿â²Ù×÷Ïà¹ØµÄ·½·¨·Åµ½Ò»¸öרߺÔðºÍÊý¾Ý¿â´ò½»µÀµÄProductRepositoryÀàÖС£Å¶Ò®£¬SRP£¡
// List 1
// ProductRepository
public Product GetProduct(int id)
{
NorthwindDataContext db = new NorthwindDataContext();
return db.Products.SingleOrDefault(p => p.id == id);
}
public void UpdateProduct(Produ
Ïà¹ØÎĵµ£º
/*
¹¦ÄÜ£ºÀûÓú¯Êý´´½¨Á÷Ë®ºÅÈ磺
fx201005260001,
fx201005260002,
fx201005270001
×÷Õߣº³ÂÓÀ½¨
´´½¨Ê±¼ä£º2010-05-26
*/
use master
go
i ......
1. ʲôÊÇÃüÃû¹ÜµÀ£¿
ÓëTCP/IP£¨´«Êä¿ØÖÆÐÒé»òinternetÐÒ飩һÑù£¬ÃüÃû¹ÜµÀÊÇÒ»ÖÖͨѶÐÒé¡£ËüÒ»°ãÓÃÓÚ¾ÖÓòÍøÖУ¬ÒòΪËüÒªÇó¿Í»§¶Ë±ØÐë¾ßÓзÃÎÊ·þÎñÆ÷×ÊÔ´µÄȨÏÞ¡£
Òª½âÊÍÕâ¸öÎÊÌ⣬ÎÒ»¹ÊÇժ¼΢Èí¹Ù·½µÄ×ÊÁϱȽϺÃ
http://msdn.microsoft.com/zh-cn/library/ms187892.aspx
ÈôÒªÁ¬½Óµ½ SQL Server Êý¾Ý¿âÒýÇ棬±ØÐëÆô ......
1¡¢×éºÏÓï¾äÖ´ÐÐ
BEGIN ATOMIC
±í´ïʽ1 ·ÖºÅ ¿Õ¸ñ/»Ø³µ
±í´ïʽ2 ·ÖºÅ ¿Õ¸ñ/»Ø³µ
END
2¡¢Ó¦¸ÃÏÞÖÆ·ÃÎÊȨÏÞµÄ±í£¨Ó¦¸Ã³·ÏúÕâЩ±íPUBLIC SELECT·ÃÎÊȨ£©
SYSCAT.DBAUTH
SYSCAT.TABAUTH
SYSCAT.PACKAGEAUTH
SYSCAT.INDEXAUTH
SYSCAT.COLAUTH
SYSCAT.PASSTHRUAUTH
SYSCAT.SCHEMAAUTH
±È½ÏÓÐÓõÄĿ¼± ......
select s.* from t_info t,t_info_class_relationship s where t.id=s.info_id and t.status is not null and s.class_id in(
select a.id
from T_INFO_CLASS a
start with a.parent_id=39902
connect by prior
a.id =parent_id u ......
³£ÓÃSQL²éѯ£º
1¡¢²é¿´±í¿Õ¼äµÄÃû³Æ¼°´óС
select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
2¡¢²é¿´±í¿Õ¼äÎïÀíÎļþµÄÃû³Æ¼°´óС
select t ......