2017-12-19 6 views
-1

私はC#wpfでフォームベースの検索のための簡単なソリューションを探しています。これは、WPFのユーザーコントロールにバインドされます c#WPFフォームベースの検索

public class Member 
{ 
    public int id { get; set; } 
    public string MNR { get; set; } 
    public int htblAnrede_id { get; set; } 
    public string Name { get; set; } 
    public string Vorname { get; set; } 
    public string Grad { get; set; } 
    public Nullable<System.DateTime> GebDat { get; set; } 
    public Nullable<System.DateTime> EinOed { get; set; } 

    public virtual htblAnrede htblAnrede { get; set; } 
    public virtual htblAusGrund htblAusGrund { get; set; } 

    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] 
    public virtual ICollection<tblBasisKennzeichen> tblBasisKennzeichen { get; set; } 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] 
    public virtual ICollection<tblBasisKontakte> tblBasisKontakte { get; set; } 
} 

よう

私のクラスが見えます。

私の場合は、フォームを開いていくつかの項目をいくつかのフィールドに書きます。その後、DataContextからすべてのプロパティ、サブオブジェクトのすべてのプロパティ、リスト内のすべてのオブジェクトのすべてのプロパティをチェックして、リスト内の一致を選択する必要があります。

これを単純化するために使用できるソリューションまたはサードパーティ製のツールはありますか、自分ですべてをチェックする必要はありますか?

+0

注釈が必要な場合があります[MSDN Docs](https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations(v = vs.110).aspx )。これにより、モデルレベルでのオブジェクトの検証が強制され、おそらく、すべての検証をUIに書き込むように保存されます。 – XAMlMAX

答えて

0

メンバークラスのequalsメソッドを、あなたが必要な場所だけでそれを呼び出す追加しない理由:

public bool Equals(Member other) 
{ 
    if(other.id != this.id) 
     return false; 

    if(!other.htblAnrede.Equals(this.htblAnrede)) 
     return false; 

    // fill in the other checks here 

    return true; 
} 

あなたは、例えば比較されているすべてのモデルのためにこれをしなければならないでしょうhtblAnrede、tblBasisKennzeichenなど