Exemplo n.º 1
0
 /// <inheritdoc/>
 public override void Inititalze(DbExpression content = null)
 {
     base.Inititalze(content);
     if (Table.InheritSets.Length == 0)
     {
         var unit = new CommitKeyUnit(Table);
         MainUnit = CreateCommitUnit(unit, Table.Members, content);
     }
     else
     {
         SubUnits = new CommitKeyUnit[Table.InheritSets.Length];
         int index = 0;
         GetTables().ForEach(
             metadata =>
         {
             var unit = new CommitKeyUnit(metadata);
             MainUnit = CreateCommitUnit(unit, metadata.Members, content);
         },
             metadata =>
         {
             var unit = new CommitKeyUnit(metadata);
             CreateCommitUnit(unit, metadata.Members, content);
             SubUnits[index++] = unit;
         });
     }
 }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public override void Inititalze(DbExpression content = null)
        {
            base.Inititalze(content);
            var table   = Table;
            var context = GenerateContext;

            if (table.InheritSets.Any())
            {
                int index = 0;
                SubUnits = new CommitKeyUnit[table.InheritSets.Length];
                table.InheritSets.Concat(new TableMetadata[] { table }).ForEach(
                    first => MainUnit = CreateMainUnit(first, content),
                    other =>
                {
                    var unit = new CommitKeyUnit(other);
                    foreach (var column in other.Keys)
                    {
                        unit.Add(CreateCommitUnitMember(column, null));
                    }
                    CreateCommitUnit(unit, other.Members, content);
                    SubUnits[index++] = unit;
                });
            }
            else
            {
                MainUnit = CreateMainUnit(table, content);
            }
        }
Exemplo n.º 3
0
        private CommitUnitBase CreateMainUnit(TableMetadata metadata, DbExpression content)
        {
            var identity = metadata.Keys.FirstOrDefault(a
                                                        => a.GeneratedForInsert != null && a.GeneratedForInsert.GeneratedOption == EGeneratedOption.Identity);

            if (identity != null)
            {
                var identityMember = new CommitMember(identity, identity.GeneratedForInsert, ECommitValueType.Database);
                var commitUnit     = new CommitIdentityUnit(metadata, identityMember);
                ReisterReturnMember(identityMember);
                CreateCommitUnit(commitUnit, metadata.Members.Where(a => a != identity), content);
                HasExpressionKey = commitUnit.Members.Any(a => a.Metadata.IsKey && a.ValueType == ECommitValueType.Expression);
                return(commitUnit);
            }
            else
            {
                var commitUnit = new CommitKeyUnit(metadata);
                CreateCommitUnit(commitUnit, metadata.Members, content);
                HasExpressionKey = commitUnit.Keys.Any(a => a.ValueType == ECommitValueType.Expression);
                return(commitUnit);
            }
        }
Exemplo n.º 4
0
 public static InsertFragment Insert(this GenerateContext context, ISourceFragment source, CommitKeyUnit target)
 {
     return(Insert(context, source, target.Table,
                   target.Keys.Concat(target.Members).Select(a => a.Metadata)));
 }