ADO.net£¬Linq to SQLºÍEntity FrameworkÐÔÄÜʵ²â·ÖÎö
ADO.net£¬Linq to SQLºÍEntity FrameworkÐÔÄÜʵ²â·ÖÎö
¡¡¡¡×î½üÎĵµÐ´Á˲»ÉÙ£¬µ¼ÖÂWordºÍExcelµÄʹÓÃÄÜÁ¦·ÉÒ»°ã³É³¤¡£¿¼Âǵ½ÏîÄ¿ÖжÁдÊý¾Ý¿âµÄ·½·¨´æÔÚЧÂʲ»¸ß£¬ÒÔÖÂÓ°ÏìÓû§ÌåÑéµÄÎÊÌ⣬¾ö¶¨²âÊÔÒ»ÏÂMicrosoftÐÂÍÆÐеÄLinqºÍEFÄܲ»ÄÜÔÚЧÂÊÉÏÓÐËù¸Ä½ø¡£
¡¡¡¡²âÊÔ»·¾³µ±È»¾ÍÊÇÎÒÕą̂±Ê¼Ç±¾ÁË£¬ÊÜÏÞÓëÓ²ÅÌתËÙ£¬ÔËÐÐÆðÀ´Ò»¶¨ÊDz»Èç̨ʽ»úµÄ£¬µ«ÖÁÉÙ±£Ö¤ÁËÈý¸ö·½°¸ÏàͬµÄÈíÓ²¼þ»·¾³£ºWindows Server 2008£¬Visual Studio 2008£¬MS SQL Server 2008£¬ÇåһɫµÄ×îвúÆ·¡£
¡¡¡¡²âÊÔ·Ö³ÉÁù¸ö½×¶Î£¬Êý¾ÝÁ¿·Ö±ðΪ10£¬10£¬100£¬1ǧ£¬1Íò£¬10ÍòÖð¼¶Ôö³¤£¬·Ö±ð²âÊÔÁ˶ÁÈ¡¡¢Ð´Èë¡¢¸ü¸Ä¡¢É¾³ýËĸö»ù±¾µÄ²Ù×÷µÄºÄʱ£¬½á¹ûÈçÏ£¨Ê±¼äµ¥Î»£ºÃ룩£º
µÚÒ»´Î¶Áд10ÌõÊý¾Ý
µÚ¶þ´Î¶Áд10ÌõÊý¾Ý
²Ù×÷100ÌõÊý¾Ý
²Ù×÷1000ÌõÊý¾Ý
²Ù×÷10000ÌõÊý¾Ý
²Ù×÷100000ÌõÊý¾Ý
¡¾²âÊÔ×ܽ᡿
¡¡¡¡µÚÒ»½×¶Î²âÊÔ½á¹û·Ç³£³öÈËÒâÁÏ£¬ADO.netºÍLINQ to SQL²Ù×÷Êý¾ÝµÄʱ¼ä¶¼¿ØÖÆÔÚ0.5ÃëÒÔÄÚ£¬·Ç³£µÄѸËÙ£¬µ«ÊÇEntity FrameworkÔÚÌí¼ÓÕâ²½±íÏַdz£²î£¬ÓÉÓÚÕâÎå²½ÊÇÁ¬Ðø²âÊÔ£¬ÆäÖÐÌí¼ÓÊý¾ÝÊǵÚÒ»²½²Ù×÷£¬¶øEFÔÚÔÚ½øÐеÚÒ»²½²Ù×÷µÄʱºò×ã×ãÑÓ³ÙÁË3ÃëÖÓ£¡Õâ3ÃëÖÓµ½µ×EFÔÚ×öʲô£¿
¡¡¡¡´ÓµÚ¶þ½×¶Î¿ªÊ¼£¬ÐÔÄܵÄÓÅÁӾͷdz£Ã÷ÏÔµÄÕ¹ÏÖÔÚÎÒÃÇÃæÇ°£¬µÚ¶þ½×¶Îµ½µÚÁù½×¶Î£¬²»ÂÛ²Ù×÷Êý¾ÝÁ¿µÄ´óС£¬Í¼ÖеĺÄʱ±ÈÀý¼¸ºõÊÇÏàͬµÄ¡£Entity FrameworkÎÞ¿ÉÕùÒéµÄÒÔ¼«¸ßµÄЧÂÊÔÚÈýÖÖ·½°¸ÖÐÍÑÓ±¶ø³ö£¬¶øLINQ to SQLµÄ¹êËÙÐ޸ĺÍɾ³ý²Ù×÷ÏûºÄµÄʱ¼ä¼¸ºõÊÇEFµÄ10±¶£¬ADO.netÔÚÌí¼ÓÊý¾ÝÉϵıíÏÖʵÔÚ²»¾¡ÈçÈËÒ⣬ÕâÒ²¸úÎÒÃÇÏîÄ¿µ×²ãд·¨Óйء£
¡¡¡¡´ÓÉÏÃæµÄ²âÊÔ½á¹û¿ÉÒÔ¿´³ö£¬³ýÈ¥EFÔÚ³õ´Î²Ù×÷Êý¾ÝÊÇÑÓ³ÙµÄ3ÃëÖÓ£¨³õ²½ÈÏΪÊdzõʼ»¯Ê±¼ä£©£¬EFµÄƽ¾ùЧÂÊÊÇLINQ to SQLµÄ6±¶£¬Êǵ±Ç°ÏîÄ¿»úÖƵÄ4±¶£¬ÕâÊǷdz£¿É¹ÛµÄЧÂÊÌáÉý£¬²»ÄÑÀí½âΪʲô΢Èí¼¸ºõ·ÅÆúÁËLINQ to SQL£¬È«Á¦Ö§³ÖEFÁË¡£
¡¾ÉîÈë·ÖÎöΪʲôµÚÒ»´ÎÖ´ÐÐEntity Framework·Ç³£ÂýµÄÔÒò¡¿£¨×ª£©
µÚÒ»´Î´´½¨ObjectContext²¢²éѯÊý¾ÝʱºÄ·ÑÁË´óÁ¿µÄʱ¼ä£¬ÔÒòÊÇʲô£¿ÓÐûÓÐʲôÓÅ»¯µÄ·½·¨£¿±¾ÎĽ«¸ø³öÒ»¸öºÏÀíµÄ½âÊÍ¡£
ÏÂÃæÕâ¸ö±ý״ͼ¸ø³öÁ˵ÚÒ»´Î´´½¨ObjectContext²¢ÓÃÆä·ÃÎÊÊý¾Ý¿âʱ¸÷ÖÖ²Ù×÷ËùÕ¼µÄʱ¼ä±È
´ÓÖпÉÒÔ¿´³ö½ö½öView GenerationÒ»¸ö²Ù×÷¾ÍÕ¼ÓÃÁË56%µÄʱ¼ä£¬²»¹ýÁîÈËÐÀοµÄÊÇ£¬Õâ¸ö²Ù×÷Ö»³öÏÖÔÚµÚÒ»´Î²éѯµÄʱºò£¬Ö®ºóÉú³ÉºÃµÄView»á±»»º´æÆðÀ´¹©ÒÔºóʹÓá£Ò»¸öView.csÎļþµÄÑù±¾ÈçÏ£º
ÎÒÃÇ¿ÉÒÔʹÓÃEDMGen2.exeÀ´×Ô¼ºÉú³ÉView.cs£¬È»º
Ïà¹ØÎĵµ£º
SQL Server2008ÐÐÊý¾ÝºÍÒ³Êý¾ÝѹËõ½âÃÜ
Êý¾ÝѹËõÒâζ׿õСÊý¾ÝµÄÓдÅÅÌÕ¼ÓÃÁ¿£¬ËùÒÔÊý¾ÝѹËõ¿ÉÒÔÓÃÔÚ±í£¬¾Û¼¯Ë÷Òý£¬·Ç¾Û¼¯Ë÷Òý£¬ÊÓͼË÷Òý»òÊÇ·ÖÇø±í£¬·ÖÇøË÷ÒýÉÏ¡£2.Ç°±êѹËõ£ºÃ¿Ò»Ò³ÖеÄËùÓÐÁУ¬ÔÚÐбêÍ·ÏÂÃ棬ÿÐж¼´æ´¢×ÅÒ»¸öÐж¨ÒåÖµ£¬Ñ¹Ëõºó£¬ËùÓÐÐеĶ¨ÒåÖµ¶¼±»Ìæ»»³ÉÐÐÍ·ÖµµÄÒýÓá£
¡¡¡¡±¾ÎĽ«Îª´ó¼Ò½éÉÜ ......
¸ñʽ:
CONVERT(data_type,expression[,style])
˵Ã÷:
´ËÑùʽһ°ãÔÚʱ¼äÀàÐÍ(datetime,smalldatetime)Óë×Ö·û´®ÀàÐÍ(nchar,nvarchar,char,varchar)
Ï໥ת»»µÄʱºò²ÅÓõ½.
Àý×Ó:
SELECT CONVERT(varchar(30),getdate(),101) now
½á¹ûΪ:
now
---------------------------------------
|09/15/2001
=============== ......
1:replace º¯Êý
µÚÒ»¸ö²ÎÊýÄãµÄ×Ö·û´®£¬µÚ¶þ¸ö²ÎÊýÄãÏëÌæ»»µÄ²¿·Ö£¬µÚÈý¸ö²ÎÊýÄãÒªÌæ»»³Éʲô
select replace('lihan','a','b')
-----------------------------
lihbn
£¨ËùÓ°ÏìµÄÐÐÊýΪ 1 ÐУ©
============================================== ......
²¢¼¯:
ʹÓà UNION ÔËËã·û×éºÏ¶à¸ö½á¹û
SELECT name,num from Table1
UNION
SELECT name,num from Table2
×¢Ò⣺²éѯµÄ×ֶθöÊý±ØÐëÏàͬ£¬Table2µÄ×Ö¶ÎÀàÐÍÒª¸úTable1µÄÏàͬ.
Èç¹ûʹÓà UNION ÔËËã·û£¬ÄÇôµ¥¶ÀµÄ SELECT Óï¾ä²»ÄÜ°üº¬Æä×Ô¼ºµÄ ORDER BY »ò COMPUTE ×Ӿ䡣ֻÄÜÔÚ×îºóÒ»¸ö SELECT Óï¾äµÄºóÃæʹÓÃÒ»¸ö ORD ......
–1¡¢²éÕÒÔ±¹¤µÄ±àºÅ¡¢ÐÕÃû¡¢²¿ÃźͳöÉúÈÕÆÚ£¬Èç¹û³öÉúÈÕÆÚΪ¿ÕÖµ£¬ÏÔʾÈÕÆÚ²»Ïê,²¢°´²¿ÃÅÅÅÐòÊä³ö,ÈÕÆÚ¸ñʽΪyyyy-mm-dd¡£
select emp_no,emp_name,dept,isnull(convert(char(10),birthday,120),’ÈÕÆÚ²»Ïê’) birthday
from employee
order by dept
–2¡¢²éÕÒÓëÓ÷×ÔÇ¿ÔÚͬһ¸öµ¥Î»µÄÔ±¹¤ÐÕÃû¡¢ ......