Beispiel #1
0
        /// <summary>
        ///   Creates a new SqlUpdate query.</summary>
        /// <param name="row">
        ///   Row with field values to set in new record (must be in TrackAssignments mode).</param>
        public SqlUpdate(IIdRow row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }

            Initialize(row.Table);

            this.Set((Row)row, (Field)(row.IdField));
            this.Where(new Criteria((Field)row.IdField) == row.IdField[(Row)row].Value);
        }
Beispiel #2
0
        public AuditSaveRequest(EntityType entityType, IIdRow oldEntity, IIdRow newEntity, Field[] auditFields)
        {
            if (newEntity == null)
                throw new ArgumentNullException("newEntity");

            if (auditFields == null)
                throw new ArgumentNullException("auditFields");

            EntityType = entityType;
            OldEntity = oldEntity;
            NewEntity = newEntity;
            AuditFields = auditFields;
        }
Beispiel #3
0
        /// <summary>
        ///   Creates a new SqlUpdate query.</summary>
        /// <param name="row">
        ///   Row with field values to set in new record (must be in TrackAssignments mode).</param>
        public static SqlUpdate ToSqlUpdateById(this IIdRow row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }

            var update = new SqlUpdate(row.Table);

            update.Set((Row)row, (Field)(row.IdField));
            update.Where(new Criteria((Field)row.IdField) == row.IdField[(Row)row].Value);

            return(update);
        }
Beispiel #4
0
        /// <summary>
        ///   Creates a new SqlUpdate query.</summary>
        /// <param name="row">
        ///   Row with field values to set in new record (must be in TrackAssignments mode).</param>
        public static SqlUpdate ToSqlUpdateById(this IIdRow row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }

            var update = new SqlUpdate(row.Table);

            var idField = row.IdField;

            update.Set(row, idField);
            update.Where(idField == new ValueCriteria(idField.AsSqlValue(row)));

            return(update);
        }
Beispiel #5
0
        /// <summary>
        ///   Creates a new SqlUpdate query.</summary>
        /// <param name="row">
        ///   Row with field values to set in new record (must be in TrackAssignments mode).</param>
        public static SqlUpdate ToSqlUpdateById(this IIdRow row, ISqlDialect dialect)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }

            var update = new SqlUpdate(dialect, row.Table, string.Empty);

            update.Set((Row)row, (Field)(row.IdField));
            var idField = (Field)row.IdField;

            update.Where(idField == new ValueCriteria(idField.AsObject((Row)row)));

            return(update);
        }
Beispiel #6
0
        public AuditSaveRequest(EntityType entityType, IIdRow oldEntity, IIdRow newEntity, Field[] auditFields)
        {
            if (newEntity == null)
            {
                throw new ArgumentNullException("newEntity");
            }

            if (auditFields == null)
            {
                throw new ArgumentNullException("auditFields");
            }

            EntityType  = entityType;
            OldEntity   = oldEntity;
            NewEntity   = newEntity;
            AuditFields = auditFields;
        }
Beispiel #7
0
        public static Dictionary <Int64, string> GetIdNameDictionary(IDbConnection connection, IIdRow row, StringField nameField,
                                                                     IEnumerable <Int64> idList)
        {
            var list       = new List <Int64>(idList);
            var dictionary = new Dictionary <Int64, string>();

            if (list.Count <= 0)
            {
                return(dictionary);
            }

            list.Sort();

            var theRow = (Row)row;

            Int64[]   part = null;
            const int step = 100;

            var i = 0;

            while (i < list.Count)
            {
                var start = i;
                var end   = start + step;
                if (end >= list.Count)
                {
                    end = list.Count - 1;
                }

                var len = end - start + 1;
                if (part == null || len != part.Length)
                {
                    part = new Int64[len];
                }

                list.CopyTo(start, part, 0, len);

                var query = new SqlQuery().Select(((Field)row.IdField).Name).Select(nameField.Name).From(theRow.Table);
                query.Where(new Criteria((Field)row.IdField).In(part));

                using (var reader = SqlHelper.ExecuteReader(connection, query))
                    while (reader.Read())
                    {
                        dictionary[reader.ToInt64(0).Value] = reader.AsString(1);
                    }

                i += step;
            }

            return(dictionary);
        }
        public static Dictionary<Int64, string> GetIdNameDictionary(IDbConnection connection, IIdRow row, StringField nameField,
            IEnumerable<Int64> idList)
        {
            var list = new List<Int64>(idList);
            var dictionary = new Dictionary<Int64, string>();
            if (list.Count <= 0)
                return dictionary;

            list.Sort();

            var theRow = (Row)row;

            Int64[] part = null;
            const int step = 100;

            var i = 0;
            while (i < list.Count)
            {
                var start = i;
                var end = start + step;
                if (end >= list.Count)
                    end = list.Count - 1;

                var len = end - start + 1;
                if (part == null || len != part.Length)
                    part = new Int64[len];

                list.CopyTo(start, part, 0, len);

                var query = new SqlQuery().Select(((Field)row.IdField).Name).Select(nameField.Name).From(theRow.Table);
                query.Where(new Criteria((Field)row.IdField).In(part));

                using (var reader = SqlHelper.ExecuteReader(connection, query))
                    while (reader.Read())
                        dictionary[reader.ToInt64(0).Value] = reader.AsString(1);

                i += step;
            }

            return dictionary;
        }