예제 #1
0
 public JoinClause(ObjectReference table, JoinType joinType, SimpleExpression joinExpression)
 {
     if (table == null) throw new ArgumentNullException("table");
     _table = table;
     _joinType = joinType;
     _joinExpression = joinExpression;
 }
예제 #2
0
 internal override IDictionary<string, object> FindOne(string tableName, SimpleExpression criteria)
 {
     try
     {
         return _adapter.FindOne(tableName, criteria);
     }
     catch (NotImplementedException)
     {
         return Find(tableName, criteria).FirstOrDefault();
     }
 }
 public IEnumerable<IDictionary<string, object>> Find(string tableName, SimpleExpression criteria, IAdapterTransaction transaction)
 {
     return Find(tableName, criteria);
 }
예제 #4
0
 internal override int Delete(string tableName, SimpleExpression criteria)
 {
     return _adapter.Delete(tableName, criteria, AdapterTransaction);
 }
예제 #5
0
 internal override IEnumerable<IDictionary<string, object>> Find(string tableName, SimpleExpression criteria)
 {
     return _adapter.Find(tableName, criteria, AdapterTransaction);
 }
예제 #6
0
 /// <summary>
 /// Finds data from the specified "table".
 /// </summary>
 /// <param name="tableName">Name of the table.</param>
 /// <param name="criteria">The criteria. This may be <c>null</c>, in which case all records should be returned.</param>
 /// <returns>The list of records matching the criteria. If no records are found, return an empty list.</returns>
 public abstract IEnumerable<IDictionary<string, object>> Find(string tableName, SimpleExpression criteria);
예제 #7
0
 /// <summary>
 /// Finds a single record.
 /// </summary>
 /// <param name="tableName">Name of the table.</param>
 /// <param name="criteria">The criteria.</param>
 /// <returns>A dictionary containing the record.</returns>
 /// <remarks>This method has a default implementation based on the <see cref="Find(string,SimpleExpression)"/> method.
 /// You should override this method if your adapter can optimize the operation.</remarks>
 public virtual IDictionary<string, object> FindOne(string tableName, SimpleExpression criteria)
 {
     return Find(tableName, criteria).FirstOrDefault();
 }
예제 #8
0
 /// <summary>
 ///  Updates the specified "table" according to specified criteria.
 ///  </summary><param name="tableName">Name of the table.</param><param name="data">The new values.</param><param name="criteria">The expression to use as criteria for the update operation.</param><returns>The number of records affected by the update operation.</returns>
 internal override int Update(string tableName, IDictionary <string, object> data, SimpleExpression criteria)
 {
     return(_adapter.Update(tableName, data, criteria));
 }
예제 #9
0
        public virtual IDictionary<string, object> Upsert(string tableName, IDictionary<string, object> dict, SimpleExpression criteriaExpression, bool isResultRequired)
        {
            if (Find(tableName, criteriaExpression).Any())
            {
                var key = GetKey(tableName, dict);
                dict = dict.Where(kvp => key.All(keyKvp => keyKvp.Key.Homogenize() != kvp.Key.Homogenize())).ToDictionary();
                Update(tableName, dict, criteriaExpression);
                return isResultRequired ? Find(tableName, criteriaExpression).FirstOrDefault() : null;
            }

            return Insert(tableName, dict, isResultRequired);
        }
 public virtual Func<object[], IDictionary<string, object>> CreateFindOneDelegate(Adapter adapter, string tableName, SimpleExpression criteria)
 {
     return adapter.CreateFindOneDelegate(tableName, criteria);
 }
예제 #11
0
 public JoinClause(ObjectReference table, SimpleExpression joinExpression) : this(table, JoinType.Inner, joinExpression)
 {
 }
예제 #12
0
 /// <summary>
 ///  Finds data from the specified "table".
 ///  </summary>
 /// <param name="tableName">Name of the table.</param>
 /// <param name="criteria">The criteria. This may be <c>null</c>, in which case all records should be returned.</param>
 /// <returns>The list of records matching the criteria. If no records are found, return an empty list.</returns>
 internal override IEnumerable <IDictionary <string, object> > Find(string tableName, SimpleExpression criteria)
 {
     return(_adapter.Find(tableName, criteria));
 }
예제 #13
0
 /// <summary>
 ///  Deletes from the specified table.
 ///  </summary><param name="tableName">Name of the table.</param><param name="criteria">The expression to use as criteria for the delete operation.</param><returns>The number of records which were deleted.</returns>
 internal override int Delete(string tableName, SimpleExpression criteria)
 {
     return(_adapter.Delete(tableName, criteria));
 }
 public int Delete(string tableName, SimpleExpression criteria, IAdapterTransaction transaction)
 {
     return Delete(tableName, criteria);
 }
예제 #15
0
        public virtual IDictionary<string, object> Upsert(string tableName, IDictionary<string, object> dict, SimpleExpression criteriaExpression, bool isResultRequired, IAdapterTransaction transaction)
        {
            var transactionAdapter = this as IAdapterWithTransactions;
            if (transactionAdapter == null) throw new NotSupportedException("Transactions are not supported with current adapter.");
            if (transactionAdapter.Find(tableName, criteriaExpression, transaction).Any())
            {
                transactionAdapter.Update(tableName, dict, criteriaExpression, transaction);
                return isResultRequired ? transactionAdapter.Find(tableName, criteriaExpression, transaction).FirstOrDefault() : null;
            }

            return transactionAdapter.Insert(tableName, dict, transaction, isResultRequired);
        }
예제 #16
0
 /// <summary>
 ///  Updates the specified "table" according to specified criteria.
 ///  </summary><param name="tableName">Name of the table.</param><param name="data">The new values.</param><param name="criteria">The expression to use as criteria for the update operation.</param><returns>The number of records affected by the update operation.</returns>
 public override int Update(string tableName, IDictionary<string, object> data, SimpleExpression criteria)
 {
     return _adapter.Update(tableName, data, criteria);
 }
예제 #17
0
 internal abstract IDictionary<string, object> FindOne(string getQualifiedName, SimpleExpression criteriaExpression);
예제 #18
0
 /// <summary>
 ///  Deletes from the specified table.
 ///  </summary><param name="tableName">Name of the table.</param>
 /// <param name="criteria">The expression to use as criteria for the delete operation.</param>
 /// <returns>The number of records which were deleted.</returns>
 public abstract int Delete(string tableName, SimpleExpression criteria);
예제 #19
0
 public SimpleQueryJoin(ObjectReference table, SimpleExpression joinExpression)
 {
     _table = table;
     _joinExpression = joinExpression;
 }
예제 #20
0
 /// <summary>
 /// Creates a delegate which can accept an array of values to use as criteria against a cached template.
 /// When called, the delegate should return zero or more records using the passed values as criteria.
 ///  </summary><param name="tableName">Name of the table.</param>
 /// <param name="criteria">The criteria to use as a template for the delegate</param>
 /// <returns>A <c>Func&lt;object[], IDictionary&lt;string, object&gt;&gt;"</c> which finds a record.</returns>
 public virtual Func<object[], IEnumerable<IDictionary<string, object>>> CreateFindDelegate(string tableName,
                                                                                            SimpleExpression
                                                                                                criteria)
 {
     throw new NotImplementedException();
 }
예제 #21
0
		public abstract object Min(string tableName, string columnName, SimpleExpression criteria);
예제 #22
0
 /// <summary>
 /// Updates the specified "table" according to specified criteria.
 /// </summary>
 /// <param name="tableName">Name of the table.</param>
 /// <param name="data">The new values.</param>
 /// <param name="criteria">The expression to use as criteria for the update operation.</param>
 /// <returns>The number of records affected by the update operation.</returns>
 public abstract int Update(string tableName, IDictionary<string, object> data, SimpleExpression criteria);
예제 #23
0
 public JoinClause(ObjectReference table, SimpleExpression joinExpression)
 {
     _table = table;
     _joinExpression = joinExpression;
 }
예제 #24
0
 internal override IDictionary<string, object> FindOne(string tableName, SimpleExpression criteria)
 {
     return _adapter.FindOne(tableName, criteria);
 }
예제 #25
0
 public override int Update(string tableName, IDictionary<string, object> data, SimpleExpression criteria)
 {
     int count = 0;
     foreach (var record in Find(tableName, criteria))
     {
         UpdateRecord(data, record);
         ++count;
     }
     return count;
 }
예제 #26
0
 internal override int Update(string tableName, IDictionary<string, object> data, SimpleExpression criteria)
 {
     return _adapter.Update(tableName, data, criteria, AdapterTransaction);
 }
예제 #27
0
 public override int Delete(string tableName, SimpleExpression criteria)
 {
     List<IDictionary<string, object>> deletions = Find(tableName, criteria).ToList();
     foreach (var record in deletions)
     {
         GetTable(tableName).Remove(record);
     }
     return deletions.Count;
 }
예제 #28
0
 internal override IDictionary<string, object> FindOne(string tableName, SimpleExpression criteria)
 {
     return Find(tableName, criteria).FirstOrDefault();
 }
예제 #29
0
 public override IEnumerable<IDictionary<string, object>> Find(string tableName, SimpleExpression criteria)
 {
     var whereClauseHandler = new WhereClauseHandler(new WhereClause(criteria));
     return whereClauseHandler.Run(GetTable(tableName));
 }
 public int Update(string tableName, IDictionary<string, object> data, SimpleExpression criteria, IAdapterTransaction transaction)
 {
     return Update(tableName, data, criteria);
 }
예제 #31
0
 public override IDictionary<string, object> Upsert(string tableName, IDictionary<string, object> dict, SimpleExpression criteriaExpression, bool isResultRequired)
 {
     return _adapter.Upsert(tableName, dict, criteriaExpression, isResultRequired, _adapterTransaction);
 }
예제 #32
0
 /// <summary>
 ///  Finds data from the specified "table".
 ///  </summary>
 /// <param name="tableName">Name of the table.</param>
 /// <param name="criteria">The criteria. This may be <c>null</c>, in which case all records should be returned.</param>
 /// <returns>The list of records matching the criteria. If no records are found, return an empty list.</returns>
 public override IEnumerable<IDictionary<string, object>> Find(string tableName, SimpleExpression criteria)
 {
     return _adapter.Find(tableName, criteria);
 }
예제 #33
0
 public virtual IDictionary<string,object> FindOne(string tableName, SimpleExpression criteria)
 {
     throw new NotImplementedException();
 }
예제 #34
0
 /// <summary>
 ///  Deletes from the specified table.
 ///  </summary><param name="tableName">Name of the table.</param><param name="criteria">The expression to use as criteria for the delete operation.</param><returns>The number of records which were deleted.</returns>
 public override int Delete(string tableName, SimpleExpression criteria)
 {
     return _adapter.Delete(tableName, criteria);
 }
예제 #35
0
 internal override IDictionary <string, object> FindOne(string tableName, SimpleExpression criteria)
 {
     return(Find(tableName, criteria).FirstOrDefault());
 }