日期:2014-05-20 浏览次数:20988 次
       class boolcompare : IComparer<bool ?>
        {
            public int Compare(bool? b1, bool? b2)
            {
                if (b1 != null && b2 != null)
                {
                    return b1.Value.CompareTo(b2.Value);
                }
                else if (b1 == null && b2== null)
                {
                    return 0;
                }
                else if (b1 == null && b2 == true)
                {
                    return 1;
                }
                else if (b1 == null && b2 == false)
                {
                    return -1;
                }
                else if (b1 == true && b2 == null)
                {
                    return -1;
                }
                else if (b1 == false && b2 == null)
                {
                    return 1;
                }
                else
                {
                    return -1;
                }
            }
            public static IComparer<bool ?> boolcompareAscending()
            {
                return (IComparer<bool ?>)(new boolcompare());
            }
        }
     public List<Information> getinforMationByReceverID(int receverID)
        {
            //临时的比较器类
            IComparer<bool?> bx = boolcompare.boolcompareAscending();
            return em.Information.Where(f => f.ReceiveUserID == receverID).OrderBy(g => (g.IfRead)).ThenBy(g => g.IfDo,bx).ThenByDescending(g => (g.SendDate)).ToList();
        }