示例#1
0
 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;
 }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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));
            }
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        public SelectBuilder <T> Where(Expression <Func <T, bool> > predicate)
        {
            CurrentQuery.WhereClause = BuilderHelper.ParseWhere(predicate);

            return(this);
        }
示例#9
0
        public UpdateBuilder <T> If(Expression <Func <T, bool> > predicate)
        {
            CurrentQuery.Conditions = BuilderHelper.ParseConditions(predicate);

            return(this);
        }