Пример #1
0
        public static SqlPredicate BuildAndNode()
        {
            var p = new SqlPredicate();

            p.predicateType = ptype.and;
            p.childNodes    = new List <SqlPredicate>();
            p.isEmpty       = true;
            return(p);
        }
Пример #2
0
 //TODO RECOURSION HANDLE
 public void Append(SqlPredicate predicate)
 {
     if (predicateType == ptype.body)
     {
         throw new InvalidOperationException("You cant append predicates to EndNodes");
     }
     if (predicate == null)
     {
         throw new ArgumentNullException();
     }
     isEmpty = false;
     childNodes.Add(predicate);
 }
Пример #3
0
        public static SqlPredicate BuildEndNode(string Key, SqlOperator op, object value, SqlType type)
        {
            if (string.IsNullOrWhiteSpace(Key) || value == null)
            {
                throw new ArgumentNullException();
            }

            var p = new SqlPredicate {
                predicateType = ptype.body,
                Key           = Key,
                op            = op,
                value         = value,
                type          = type
            };

            p.isEmpty = false;
            return(p);
        }
Пример #4
0
        /// <summary>
        /// table - name of table,
        /// fieldNames - array of column names,
        /// condition - SqlPredicate Graph
        /// </summary>
        public IList <IDictionary <string, object> > FetchDataDistinct(IEnumerable <string> fieldNames, string table, string schema = "dbo", SqlPredicate condition = null)
        {
            string cond    = condition == null || condition.CheckEmptiness() ? null : "WHERE " + condition.ToSqlString();
            string command = MakeCommand(true, fieldNames, table, schema, cond);

            return(FetchData(command, reader => {
                var dict = new Dictionary <string, object>();
                foreach (var field in fieldNames)
                {
                    dict.Add(field, reader[field]);
                }
                return dict as IDictionary <string, object>;
            }));
        }