public void TestWhere_Criteria() { _query.Where(new CriteriaSample()); Assert.Equal("t => ((t.Name == \"A\") AndAlso (t.Tel == 1))", _query.GetPredicate().ToString()); _query = new Query <AggregateRootSample>(); _query.Where(new DefaultCriteria <AggregateRootSample>(t => t.Name == null)); Assert.NotNull(_query.GetPredicate()); }
public TEntity GetSingle(IExpressionQuery <TEntity> queryCriteria) { if (queryCriteria != null) { var resultList = queryCriteria.Execute(Set).FirstOrDefault(); return(resultList); } return(FirstOrDefault()); }
public IEnumerable <TEntity> GetList(IExpressionQuery <TEntity> queryCriteria) { if (queryCriteria != null) { var predicate = queryCriteria.BuildExpression(); return(GetList(predicate)); } return(GetList()); }
public static IQueryable <T> LoadWith <T>( [NotNull] this IExpressionQuery <T> table, [NotNull, InstantHandle] Expression <Func <T, object> > selector) { if (table == null) { throw new ArgumentNullException(nameof(table)); } table.Expression = GetExpressionLoadWith(table.Expression, selector); return(table); }
public void TestOrderBy() { QueryParameterSample sample = new QueryParameterSample { Order = "Name" }; _query = new Query <AggregateRootSample>(sample); Assert.Equal("Name", _query.GetOrder()); _query.OrderBy("Age", true); Assert.Equal("Name,Age desc", _query.GetOrder()); _query.OrderBy(t => t.Tel, true); Assert.Equal("Name,Age desc,Tel desc", _query.GetOrder()); }
public void TestWhere() { _query.Where(t => t.Name == "A"); Assert.Equal("t => (t.Name == \"A\")", ZKCloud.Extensions.Extensions.SafeString(_query.GetPredicate())); _query.Where(t => t.Tel == 1); Assert.Equal("t => ((t.Name == \"A\") AndAlso (t.Tel == 1))", ZKCloud.Extensions.Extensions.SafeString(_query.GetPredicate())); _query = new Query <AggregateRootSample>(); _query.Where(t => t.Name == "A" && t.Tel == 1); Assert.Equal("t => ((t.Name == \"A\") AndAlso (t.Tel == 1))", ZKCloud.Extensions.Extensions.SafeString(_query.GetPredicate())); _query = new Query <AggregateRootSample>(); _query.Where(t => t.Name == ""); Assert.NotNull(_query.GetPredicate()); }
public void TestGetPager() { QueryParameterSample sample = new QueryParameterSample() { Order = "A", Page = 2, PageSize = 30, TotalCount = 40 }; _query = new Query <AggregateRootSample>(sample); _query.OrderBy("B", true); var pager = _query.GetPager(); Assert.Equal(2, pager.Page); Assert.Equal(30, pager.PageSize); Assert.Equal(40, pager.TotalCount); Assert.Equal("A,B desc", pager.Order); }
private static void InitParameters <T>(IExpressionQuery eq, Query <T> info, Expression expression) { eq.DataContext.GetQueryRunner(info, 0, expression, null, null).GetSqlText(); }
public TEntity GetSingle(IExpressionQuery <TEntity> query) { return(Store.GetSingle(query)); }
public async Task <IEnumerable <TEntity> > GetListAsync(IExpressionQuery <TEntity> query) { // return await Store.GetList(query).ToList(); throw new NotImplementedException(); }
public IList <TEntity> GetList(IExpressionQuery <TEntity> queryCriteria) { return(Store.GetList(queryCriteria).ToList()); }
/// <summary> /// This is internal API and is not intended for use by Linq To DB applications. /// It may change or be removed without further notice. /// </summary> public static IDataContext GetDataContext <T>(IQueryable <T> queryable) { return(queryable switch { IExpressionQuery query => query.DataContext, _ => default !,