private Func <MyType, bool> Criteria2ToPredicate() { if (Criteria2 == null) { return((obj) => true); } // if you cannot use contains, you can use Any return((obj) => Criteria2.Any(critVal => obj.Criteria2 == critVal)); }
public override int GetHashCode() { unchecked { var hashCode = Name != null?Name.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (Criteria1 != null ? Criteria1.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Criteria2 != null ? Criteria2.GetHashCode() : 0); return(hashCode); } }
/// <summary> /// Creates or loads a <see cref="SampleUnitOfWork"/> unit of objects, based on given criteria. /// </summary> /// <param name="crit">The create/fetch criteria.</param> protected void DataPortal_Fetch(Criteria2 crit) { if (crit.CreateDoc) { LoadProperty(DocProperty, Doc.NewDoc()); } else { LoadProperty(DocProperty, Doc.GetDoc(crit.DocID)); } if (crit.CreateFolder) { LoadProperty(FolderProperty, Folder.NewFolder()); } else { LoadProperty(FolderProperty, Folder.GetFolder(crit.FolderID)); } LoadProperty(DocListProperty, DocList.GetDocList(crit.DocListFilteredCriteria)); }