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

LINQ to Entities ʵÏÖsql ¹Ø¼ü×Ö"In"·½Ê½×ܽá

ÔÚLINQ to EntitiesÖÐûÓа취ÔÙÏñ LINQ to SQL ÖÐÒ»ÑùʹÓà Contains µÄ·½·¨À´ÊµÏÖsql "in" ¹Ø¼ü×Ö
ÏÂÃæ´úÂëÔÚ LINQ to SQL ÖпÉÐÐ ÔÚLINQ to EntitiesÈ´ÎÞ·¨ÔËÐУº 
var s = db.Account.Select(c => c.ID);
var ret =(from t in db.Profile
 where s.Contains(t.ID)
 select t).ToList();
Ìæ´ú·½·¨1:ʹÓ÷½·¨Any
var ids=db.Account.Select(c => c.ID);
var ret = (from t in db.Profile where ids.Any(c=>c==t.UserID) select t).ToList();
ʹÓ÷½·¨AnyÌæ»»·¨¸ãÁ˺þö¼Ã»·¨ÊµÏÖÖ±½Ó¶ÔÊý×éAny£¬ÏÂÁдúÂëÈÔÎÞ·¨Ö´ÐУº
int[] ids = new int[]{10101,10005,10007};
var ret = (from t in db.Profile where ids.Any(c=>c==t.UserID) select t).ToList();
ÓÚÊǼÌÐøGoolgeѰÕÒµÚ¶þÖÖ·½·¨£¬ÔÚMSDNÂÛ̳ÉÏÕÒÒ»¸ö¹¹ÔìLambdaÓï¾äµÄ·½·¨
Ìæ´ú·½·¨2:¹¹ÔìLambdaÓï¾ä
        private static Expression<Func<TElement, bool>> BuildWhereInExpression<TElement, TValue>(Expression<Func<TElement, TValue>> propertySelector, IEnumerable<TValue> values)
        {
            ParameterExpression p = propertySelector.Parameters.Single();
            if (!values.Any())
                return e => false;
            var equals = values.Select(value => (Expression)Expression.Equal(propertySelector.Body, Expression.Constant(value, typeof(TValue))));
            var body&


Ïà¹ØÎĵµ£º

sqlÖÐCASEµÄÓ÷¨

 
À´Ô´:SQL°ïÖúÎĵµ
CASE
¼ÆËãÌõ¼þÁÐ±í²¢·µ»Ø¶à¸ö¿ÉÄܽá¹û±í´ïʽ֮һ¡£
CASE ¾ßÓÐÁ½ÖÖ¸ñʽ£º
¼òµ¥ CASE º¯Êý½«Ä³¸ö±í´ïʽÓëÒ»×é¼òµ¥±í´ïʽ½øÐбȽÏÒÔÈ·¶¨½á¹û¡£
CASE ËÑË÷º¯Êý¼ÆËãÒ»×é²¼¶û±í´ïʽÒÔÈ·¶¨½á¹û¡£
Á½ÖÖ¸ñʽ¶¼Ö§³Ö¿ÉÑ¡µÄ ELSE ²ÎÊý¡£
Óï·¨
¼òµ¥ CASE º¯Êý£º
CASE input_expression
 &n ......

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

PowerBuilderÊÇĿǰ×îÁ÷ÐеÄÊý¾Ý¿â¿ª·¢¹¤¾ßÖ®Ò»¡£PowerBuilderÌṩÁËÔÚ³ÌÐò´úÂëÖмÓÈëǶÈëʽSQLÓï¾äµÄ¹¦ÄÜÀ´Ö§³Ö¶ÔÊý¾Ý¿âµÄ·ÃÎÊ¡£µ«ÕâÖÖǶÈëʽSQLÓï¾äÖ»ÄÜÖ§³ÖһЩ¹Ì¶¨µÄ±ê×¼µÄSQLÓï¾ä£¬¼´ÔÚ½øÐгÌÐò´úÂë±àÒë´¦ÀíʱÕâЩSQLÓï¾ä±ØÐëÊÇÈ·¶¨µÄ£¬ÀýÈ磺¶ÔÄÄÕűíÄö×ֶνøÐвÙ×÷ÔÚ³ÌÐò´úÂëÖÐÊǹ̶¨Ð´Ã÷µÄ£¬ÁíÍâÕâÖÖ·½Ê½Ò²²»ÄÜ ......

sql group by Óë havingµÄÓ÷¨

1. GROUP BY ÊÇ·Ö×é²éѯ, Ò»°ã GROUP BY ÊǺ;ۺϺ¯ÊýÅäºÏʹÓÃ
group by ÓÐÒ»¸öÔ­Ôò,¾ÍÊÇ select ºóÃæµÄËùÓÐÁÐÖÐ,ûÓÐʹÓþۺϺ¯ÊýµÄÁÐ,±ØÐë³öÏÖÔÚ group by ºóÃæ£¨ÖØÒª£©
ÀýÈç,ÓÐÈçÏÂÊý¾Ý¿â±í£º
A    B
1    abc
1    bcd
1    asdfg
 Èç¹ûÓÐÈ ......

[Sql Server2008]Ê÷½á¹¹µÄµÝ¹éËã·¨

±¾ÎÄÖ÷Òª½²ÊöÈý¸öÄÚÈÝ£º
1.ÈçºÎ´´½¨hierarychyidµÄ±í£¬²åÈëÊý¾Ý¼°»ù±¾µÝ¹é²éѯ¡£
2.½éÉÜhierarchyidµÄ10ÖÖרÓк¯Êý¡£
3.½éÉÜhierarchyidÌØÓеÄÉî¶ÈÓÅÏÈË÷Òý(Depth-First Indexing)ºÍ¹ã¶ÈÓÅÏÈË÷Òý(Breadth-First Indexing)
ÔÚÉÏÒ»½ÚÖÐ
http://blog.csdn.net/tjvictor/archive/2009/07/30/4395677.aspx
ÎÒÃÇÒѾ­ÑÝ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ