public QueryBuilder() { Session = GlobalConfiguration.Current.Session; BuilderHelper = new BuilderHelper <T, TItem>(this, GlobalConfiguration.Current.UseBindings); Parameters = new Dictionary <string, object>(); CurrentQuery = new T(); CurrentQuery.TableName = TableCache <TItem> .CachedTable.TableName; CurrentQuery.KeyspaceName = TableCache <TItem> .CachedTable.KeyspaceName; }
public UpdateBuilder <T> Set(Expression <Func <T, object> > select, Assignment.CounterModifierTypes counterModifierType, object value) { string selection = BuilderHelper.ParseSimpleMemberAccess(select); if (selection != null) { CurrentQuery.Assignments.Add(new Assignment(selection, counterModifierType, GenerateBindMarker(value))); } return(this); }
public UpdateBuilder <T> Set(Expression <Func <T, object> > select, object value) { SimpleSelection selection = BuilderHelper.ParseSimpleSelection(select); if (selection != null) { CurrentQuery.Assignments.Add(new Assignment(selection, GenerateBindMarker(value))); } return(this); }
public DeleteBuilder <T> Delete(params Expression <Func <T, object> >[] selects) { if (selects != null) { foreach (Expression <Func <T, object> > select in selects) { SimpleSelection selection = BuilderHelper.ParseSimpleSelection(select); if (selection != null) { CurrentQuery.Selections.Add(selection); } } } return(this); }
private void BaseAlterSet <TItem>(Expression <Func <T, ISet <TItem> > > select, ISet <TItem> values, Assignment.CollectionModifierTypes modifierType) { string selection = BuilderHelper.ParseSimpleMemberAccess(select); if (values != null && selection != null) { ISet <Term> translatedList = new HashSet <Term>(); foreach (TItem value in values) { translatedList.Add(GenerateBindMarker(value)); } CollectionLiteral literal = new CollectionLiteral(translatedList); CurrentQuery.Assignments.Add(new Assignment(selection, modifierType, literal)); } }
public UpdateBuilder <T> AddToMap <TKey, TValue>(Expression <Func <T, IDictionary <TKey, TValue> > > select, IDictionary <TKey, TValue> values) { string selection = BuilderHelper.ParseSimpleMemberAccess(select); if (selection != null && values != null) { IDictionary <Term, Term> translated = new Dictionary <Term, Term>(); foreach (KeyValuePair <TKey, TValue> value in values) { translated.Add(GenerateBindMarker(value.Key), GenerateBindMarker(value.Value)); } CollectionLiteral literal = new CollectionLiteral(translated); CurrentQuery.Assignments.Add(new Assignment(selection, Assignment.CollectionModifierTypes.Add, literal)); } return(this); }
public UpdateBuilder <T> RemoveFromMap <TKey, TValue>(Expression <Func <T, IDictionary <TKey, TValue> > > select, ISet <TKey> keys) { string selection = BuilderHelper.ParseSimpleMemberAccess(select); if (keys != null && selection != null) { ISet <Term> translatedList = new HashSet <Term>(); foreach (TKey value in keys) { translatedList.Add(GenerateBindMarker(value)); } CollectionLiteral literal = new CollectionLiteral(translatedList); CurrentQuery.Assignments.Add(new Assignment(selection, Assignment.CollectionModifierTypes.Remove, literal)); } return(this); }
public SelectBuilder <T> Where(Expression <Func <T, bool> > predicate) { CurrentQuery.WhereClause = BuilderHelper.ParseWhere(predicate); return(this); }
public UpdateBuilder <T> If(Expression <Func <T, bool> > predicate) { CurrentQuery.Conditions = BuilderHelper.ParseConditions(predicate); return(this); }