Exemple #1
0
 /**
  * Filters the set based on the dynamic string expression, using sql
  * LIKE clauses. This does not return results but a new filtered
  * Linq<TModel>.
  *
  * ```cs
  *  var filteredEntities = Models.Foo.Like("e => e.Bar == \"%abc%\"");
  * ```
  *
  * > NOTE: You may use ```!=``` for a NOT LIKE query.
  */
 public Linq <TModel> Like(string predicate)
 {
     return(this.Like
            (
                ExpressionBuilder.BuildPredicateExpression <TModel>(predicate)
            ));
 }
Exemple #2
0
 /**
  * Updates enMasse using a dynamic string expression.
  *
  * ```cs
  *  Models.Foo.UpdateAll("e => e.Bar == \"abc\" && e.Baz == 123");
  * ```
  *
  * > NOTE: This is NOT a "WHERE" predicate. The expression you provide
  * > this Update method follows the same structure as a predicate but
  * > we parse it slightly diffrently. Consider each "&&" or "||" as a
  * > comma. And each "==" simply as a "=" operator.
  */
 public void UpdateAll(string assignments)
 {
     this.UpdateAll
     (
         ExpressionBuilder.BuildPredicateExpression <TModel>(assignments)
     );
 }
Exemple #3
0
 /**
  * Returns the only element of the set that matches the dynamic string
  * expression, or a default value if the set is empty; this method
  * throws an exception if there is more than one element in the set.
  *
  * ```cs
  *  var entity = Models.Foo.SingleOrDefault("e => e.Bar == \"abc\"");
  * ```
  */
 public TModel SingleOrDefault(string predicate)
 {
     return(this.SingleOrDefault
            (
                ExpressionBuilder.BuildPredicateExpression <TModel>(predicate)
            ));
 }
Exemple #4
0
 /**
  * Returns the first entity that matches the dynamic string expression.
  *
  * ```cs
  *  var entity = Models.Foo.First("e => e.Bar == \"abc\"");
  * ```
  */
 public TModel First(string predicate)
 {
     return(this.First
            (
                ExpressionBuilder.BuildPredicateExpression <TModel>(predicate)
            ));
 }
Exemple #5
0
 /**
  * Number of entities that match the dynamic string expression.
  *
  * ```cs
  *  var numberOfEntities = Models.Foo.Count("e => e.Bar == \"abc\"");
  * ```
  */
 public int Count(string predicate)
 {
     return(this.Count
            (
                ExpressionBuilder.BuildPredicateExpression <TModel>(predicate)
            ));
 }
Exemple #6
0
 /**
  * Do any entities in the set pass the dynamic string expression?
  *
  * ```cs
  *  if (Models.Foo.Any("e => e.Bar == \"abc\""))
  *  {
  *      // At least one Foo has it's Bar property set to abc
  *  }
  *  else
  *  {
  *      // No Foo's have their Bar property set to abc
  *  }
  * ```
  */
 public bool Any(string predicate)
 {
     return(this.Any
            (
                ExpressionBuilder.BuildPredicateExpression <TModel>(predicate)
            ));
 }
Exemple #7
0
 /**
  * Orders the set based on the dynamic string expression.
  *
  * ```cs
  *  var orderedEntities = Models.Foo
  *  .OrderBy("e => e.Bar", OrderDirection.DESC)
  *  .OrderBy("e => e.Baz", OrderDirection.ASC);
  * ```
  *
  * > NOTE: ASC is the default direction, if not supplied.
  */
 public Linq <TModel> OrderBy(string predicate, OrderDirection direction = OrderDirection.ASC)
 {
     return(this.OrderBy
            (
                ExpressionBuilder.BuildPropertySelectExpression <TModel>(predicate),
                direction
            ));
 }