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

LINQ to SQL ÐÔÄÜ 10 Tips


LINQ to SQL ÐÔÄÜ 10 Tips
http://www.cnblogs.com/worksguo/archive/2008/06/04/1213075.html
Ç°Ò»ÖÜ£¬ÎÒµÄÓ²ÅÌÓÐÁ½·ÖÇø»µÁË£¬ÎÒ×¼±¸µÄÎÄÕÂÓë×ÊÁ϶¼ÔÚÀïÃ棬ËùÒÔLINQµÄÎÄÕÂÍ£ÁËÒ»¶Îʱ¼ä£¬ÕæµÄÌ«²»ºÃÀ­£¬ÎªÀ´ÃÖ²¹Ò»Ï¾ÍÏÈ·¢ÕâƪÎÄÕÂÉÏÀ­£¬Ã÷ÌìÔÙһƪ¹ØÓÚDisconnection DataµÄÎÄÕ¡£
Ö»²»¹ýÐҺã¬ÔÚÕ⼸ÌìÖÐÎҽ߾¡È«Á¦»Ö¸´ÕâЩÊý¾Ý£¬¾­¹ý3ÌìµÄŬÁ¦ÖÕÓÚÊÇÈ«²¿ÕÒ»ØÀ´À­¡£
ÏÂÃæÊÇһЩÌÖÂÛLINQ to SQLÐÔÄÜһЩÎÄÕ¡£
http://blogs.msdn.com/ricom/archive/2007/06/22/dlinq-linq-to-sql-performance-part-1.aspx
http://www.jdconley.com/blog/archive/2007/11/28/linq-to-sql-surprise-performance-hit.aspx
"LINQ Changes How You Will Program" by Bill McCarthy.
"Layer Data Access with LINQ to SQL" by Roger Jennings.
1:¹Ø±ÕOjectTrackingEnabledÊôÐÔ.
Èç¹ûÄãÖ»ÊÇÕÒ»ØÊý¾Ý,²¢ÇÒ²»ÐÞ¸ÄÈκζ«Î÷,Äã²»ÐèÒªobjectTracking,ËùÓоÍÏñÏÂÃæÒ»Ñù:
using (NorthwindDataContext context = new NorthwindDataContext())
{
  context.ObjectTrackingEnabled = false;
}
2:²»Òª½«ÄãµÄËùÓÐDB Object¶¼·ÅÈëµ¥¸öDataContextÖÐ.
DataContext±íʾһ¸öµ¥¶ÀµÄ¹¤×÷µ¥Ôª,¶ø²»ÊÇÄãÊý¾Ý¿âÈ«²¿.ÈçÈôÄãÓжà¸öûÓÐÁ¬½ÓµÄÊý¾Ý¿â¶ÔÏó,»òËûÃÇûÓб»Ê¹ÓÃ.ÕâЩ¶ÔÏó¾Í²»ÐèÒªÌí¼Ó½øÄÚ´æÖеıêʶ¹ÜÀíÖÐÏûºÄµÄÄÚ´æ¿Õ¼äºÍÔÚDataContextµÄCUD engine¸ú×Ù¶ÔÏóµÄ»¨·Ñ.
ÎÒ½¨ÒéÄ㽫ÄãµÄ¹¤×÷Êý¾ÝÇøÓò·Ö¸î¼¸¸öDataContexts,ÿһ¸öÇøÓò±íʾһ¸öµ¥¶ÀµÄʹÓÃÊý¾ÝµÄ¹¤×÷µ¥Ôª.Ä㻹ÊÇÄÜʹÓÃͬһ¸öÁ¬½Ó.
3:²»ÒªÊ¹Óà CompiledQuery
µ±Äã´´½¨ºÍÖ´ÐÐÄãµÄ²éѯ,´Óexpressionµ½ÏàÓ¦µÄSQL,Óм¸¸ö²½Öè:
   1.
      Create expression tree(´´½¨±í´ïÊ÷)
   2.
      Convert it to SQL(ת»»SQL)
   3.
      Run the query(ÔËÐвéѯ)
   4.
      Retrieve the data(ÕÒ»ØÊý¾Ý)
   5.
      Convert it to the objects(ת»»Îª¶ÔÏó)
Äã×¢Òâ:µ±ÄãʹÓÃÒ»´ÎÒ»´ÎʹÓÃͬһ¸ö²éѯʱ,µÚÒ»ºÍµÚ¶þ²½ÊÇ×îºÄ·Ñʱ¼ä.
ÕâÀïÒªÉÙʹÓÃÓÃÀ´CompiledQueryµÄÔÚSystem.Data.Linq ÃüÃû¿Õ¼äÖеÄÀà,ʹÓÃCompiledQuery,ÄãÒ»´Î±àÒëÄãµÄ²éѯ²¢ÇÒ´æ´¢ËüÔÚÖ®ºóʹÓõĵط


Ïà¹ØÎĵµ£º

¡¾×ª¡¿ÈçºÎ²é¿´oracle sqlÖ´Ðмƻ®

·½·¨Ò»
µÚÒ»²½£ºµÇÈësql/plus Ö´ÐÐÃüÁÎÞÏȺó˳Ðò£©
set   time   on; (˵Ã÷£º´ò¿ªÊ±¼äÏÔʾ£©  
  set   autotrace   on; (˵Ã÷£º´ò¿ª×Ô¶¯·ÖÎöͳ¼Æ£¬²¢ÏÔʾSQLÓï¾äµÄÔËÐнá¹û£©  
  set   autotrace   traceonly; (˵à ......

ʹÓÃsql server·ÖÎöϵͳÈÕÖ¾(תÔØ×Ôneeao.com)

1.·ÖÎöϵͳÈÕÖ¾£¬Ò»ÐÐÒ»Ðп´×ÅʵÔÚÀÛÈË£¬ºÜ¶àÎÞ¹ØÈÕÖ¾£¬ÄܹýÂËϾͺÃÁË¡£Îı¾¹¤¾ß¹¦ÄÜʵÔÚÓÐÏÞ£¬ÓÚÊǺõ£¬½«windowsϵͳÈÕÖ¾µ¼Èësql serverÖУ¬Ö±½ÓsqlÖ®……¡£ÊµÑéÁ˼¸°Ñ£¬×îºÃµÄÊÇ£¬Ö±½Ó½«ÏµÍ³ÈÕÖ¾µ¼³öΪÎı¾µÄ£¬Ö±½Ótab·Ö¸îµÄ£¬µ¼ÈësqlµÄʱºò£º
н¨Êý¾Ý¿â->µ¼ÈëÊý¾Ý->ÏÂÒ»²½->Êý¾ÝÔ´Ñ¡ÔñÎı¾Îļþ- ......

BuildQuery A Simple SQL Query Tool

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BuildQuery
{
/// <summary>
/// ʹÓÃÌṩµÄÊý¾Ý½¨Á¢Ò»¸öSQL²éѯ
/// </summary>
public class BuildQuery
{
#region ÀàµÄ±äÁ¿
int numFieldsCount, ......

SQL´æ´¢¹ý³Ì ¸ÅÊö

1.sql´æ´¢¹ý³Ì¸ÅÊö
2.SQL´æ´¢¹ý³Ì´´½¨
3.sql´æ´¢¹ý³Ì¼°Ó¦ÓÃ
4.¸÷ÖÖ´æ´¢¹ý³ÌʹÓÃÖ¸ÄÏ
5.ASPÖд洢¹ý³Ìµ÷ÓõÄÁ½ÖÖ·½Ê½¼°±È½Ï
6.SQL´æ´¢¹ý³ÌÔÚ.NETÊý¾Ý¿âÖеÄÓ¦ÓÃ
7.ʹÓÃSQL´æ´¢¹ý³ÌÒªÌرð×¢ÒâµÄÎÊÌâ
1.sql´æ´¢¹ý³Ì¸ÅÊö
ÔÚ´óÐÍÊý¾Ý¿âϵͳÖУ¬´æ´¢¹ý³ÌºÍ´¥·¢Æ÷¾ßÓкÜÖØÒªµÄ×÷Óá£ÎÞÂÛÊÇ´æ´¢¹ý³Ì»¹ÊÇ´¥·¢Æ÷£¬¶¼ÊÇSQL Óï ......

¡¾Õª¡¿Power Builder Öж¯Ì¬SQLÓï¾äµÄд·¨

PowerBuilderÊÇÄ¿Ç°×îÁ÷ÐеÄÊý¾Ý¿â¿ª·¢¹¤¾ßÖ®Ò»¡£PowerBuilderÌṩÁËÔÚ³ÌÐò´úÂëÖмÓÈëǶÈëʽSQLÓï¾äµÄ¹¦ÄÜÀ´Ö§³Ö¶ÔÊý¾Ý¿âµÄ·ÃÎÊ¡£µ«ÕâÖÖǶÈëʽSQLÓï¾äÖ»ÄÜÖ§³ÖһЩ¹Ì¶¨µÄ±ê×¼µÄSQLÓï¾ä£¬¼´ÔÚ½øÐгÌÐò´úÂë±àÒë´¦ÀíʱÕâЩSQLÓï¾ä±ØÐëÊÇÈ·¶¨µÄ£¬ÀýÈ磺¶ÔÄÄÕűíÄļ¸¸ö×ֶνøÐвÙ×÷ÔÚ³ÌÐò´úÂëÖÐÊǹ̶¨Ð´Ã÷µÄ£¬ÁíÍâÕâÖÖ·½Ê½Ò²²»ÄÜ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ