2012-02-25 6 views
0

私はLINQクエリでデータを取得します選択した期間のために一意である(日付フォーマット1/1/1990から1/1/1991年である)テーブル<strong>列コード、金額、説明、 は、データコードを取得するLINQクエリを記述し、同じコードと説明があるかもしれません選択した期間の有効期間 とStudentAccount</strong>は/説明する必要

+2

uはそれは愚かなcomments..problemが小さいか大きいことができ作るfine..dont答えることができthis..ifのようにどのようにuは言うことができます – GANI

答えて

1
public IEnumerable<StudentAccount> StudentAccountdata 
    { 
     get { return Context.StudentAccount.Where(q=>q.Active).OrderBy(q =>q.Description).ToList(); }    
    } 

使用IEqualityComparerようなので:

public class StdComparer : IEqualityComparer<StudentAccount> 
{ 
    #region IEqualityComparer<StudentAccount> Members 

    public bool Equals(StudentAccount x, StudentAccount y) 
    { 
     return x.Code == y.Code && x.Description == y.Description; 
    } 

    public int GetHashCode(StudentAccount obj) 
    { 
     return 0; 
    } 

    #endregion 
} 

nは

public IEnumerable<StudentAccount> StudentAccountdata 
{ 
    get { return Context.StudentAccount.Where(q=>q.Active && 
        q.Date >= BeginDate && 
        q.Date <= EndDate) 
        .OrderBy(q =>q.Description).Distinct(new StdComparer()); } 
}