Example #1
0
        void DoWithWhere(SoodaObject obj, StringBuilder builder, ArrayList queryParams, bool isRaw)
        {
            builder.Append(" where ");
            object primaryKeyValue = obj.GetPrimaryKeyValue();

            FieldInfo[] primaryKeyFields = obj.GetClassInfo().GetPrimaryKeyFields();
            for (int i = 0; i < primaryKeyFields.Length; i++)
            {
                if (i > 0)
                {
                    builder.Append(" and ");
                }
                FieldEquals(primaryKeyFields[i], SoodaTuple.GetValue(primaryKeyValue, i), builder, queryParams);
            }
            SqlBuilder.BuildCommandWithParameters(_updateCommand, true, builder.ToString(), queryParams.ToArray(), isRaw);
            FlushUpdateCommand(false);
        }
Example #2
0
        public override IDataReader LoadObjectTable(SoodaObject obj, object keyVal, int tableNumber, out TableInfo[] loadedTables)
        {
            ClassInfo  classInfo = obj.GetClassInfo();
            IDbCommand cmd       = Connection.CreateCommand();

            try
            {
                cmd.CommandTimeout = CommandTimeout;
            }
            catch (NotSupportedException e)
            {
                logger.Debug("CommandTimeout not supported. {0}", e.Message);
            }

            if (Transaction != null)
            {
                cmd.Transaction = this.Transaction;
            }

            SqlBuilder.BuildCommandWithParameters(cmd, false, GetLoadingSelectStatement(classInfo, classInfo.UnifiedTables[tableNumber], out loadedTables), SoodaTuple.GetValuesArray(keyVal), false);
            IDataReader reader = TimedExecuteReader(cmd);

            if (reader.Read())
            {
                return(reader);
            }
            else
            {
                reader.Dispose();
                return(null);
            }
        }