Beispiel #1
0
        public async Task <TModel> Find(IStoredProcedureQuery namedQuery)
        {
            var results = await FindAll(namedQuery);

            Invariant.IsFalse(results.Count() > 1, () => "More than one result found for query: {0}".FormatInvariantCulture(this));
            return(results.FirstOrDefault());
        }
Beispiel #2
0
        public TDomainCriteria BuildDomainCriteria()
        {
            criteria = new TDomainCriteria
            {
                MaximumResult = MaximumResults,
                FirstResult   = FirstResult,
                SortOrder     = sortOrder
            };
            criteria.SafeAnd(new EqualityFilter("Id", Id));

            if (Ids.IsNotNull() && Ids.Count() > 0)
            {
                criteria.SafeAnd(new EqualityFilter("Id", Ids, FilterType.In));
            }

            if (NotEqualIds.IsNotNull() && NotEqualIds.Count() > 0)
            {
                criteria.SafeAnd(new EqualityFilter("Id", NotEqualIds, FilterType.NotIn));
            }

            criteria.Aggregations.AddRange(Aggregations);

            OnBuildDomainCriteria(criteria);

            if (FailOnNoCriteriaSpecified)
            {
                Invariant.IsFalse(criteria.IsEmpty(), () => "Criteria requires at least one filter");
            }

            return(criteria);
        }
 private void VerifyOneResult(IEnumerable <TDomain> results)
 {
     Invariant.IsFalse(results.Count() > 1, () => "More than one result found for query: {0}".FormatInvariantCulture(this));
 }
 public static void RequiredAnd(this DomainCriteria value, EqualityFilter filter)
 {
     Invariant.IsFalse(filter.IsNull() || filter.Value.IsNull() || (filter.Value is string && filter.Value.AsString().IsNullOrEmpty()), () => "'{0}' filter is required".FormatInvariantCulture(filter.Property));
     value.SafeAnd(filter);
 }