Example #1
0
        private string GetSql()
        {
            var table = this.Target;
            var sql   = new SqlUpdateBuilder();

            sql.SetTable(table.Name);

            sql.Set(string.Format("{0}={0}+1", SqlStatement.Qualifier(GeneratedField.DataVersionName)));

            foreach (var field in table.PrimaryKeys)
            {
                sql.Where(field.Name);
            }

            return(sql.GetCommandText());
        }
Example #2
0
        private static string GetUpdateSql(DataTable table, DynamicData data)
        {
            var sql = new SqlUpdateBuilder();

            sql.SetTable(table.Name);

            foreach (var p in data)
            {
                var field = p.Key;
                if (field.EqualsIgnoreCase(EntityObject.IdPropertyName))
                {
                    continue;                                                      //不修改id和rooid
                }
                if (table.Type != DataTableType.AggregateRoot)
                {
                    if (field.EqualsIgnoreCase(GeneratedField.RootIdName))
                    {
                        continue;                                                    //不修改rooid
                    }
                }
                sql.AddField(field);
            }

            //if (!table.IsDerived)
            //{
            //    //更新数据版本号
            //    sql.Set(string.Format("[{0}]=[{0}]+1", GeneratedField.DataVersionName));
            //}

            foreach (var field in table.PrimaryKeys)
            {
                sql.Where(field.Name);
            }

            if (table.IsEnabledMultiTenancy)
            {
                sql.Where(GeneratedField.TenantIdName);
            }

            return(sql.GetCommandText());
        }