Ejemplo n.º 1
0
        //生成语句插入的成员。
        private void GenerateForInsertStatementMembers(GenerateContext context, DbNewExpression newitem,
                                                       QueryBaseFragment source, InsertFragment insert, Func <PropertyInfo, ColumnMetadata> getmember)
        {
            int count = 0;

            foreach (var item in newitem.Members)
            {
                count++;
                insert.CreateMember(null, getmember((PropertyInfo)item.Key));
                IMemberFragment member = null;
                if (_CreateExpressionMethods.TryGetValue(item.Value.ExpressionType, out CreateExpressionDelegate method))
                {
                    member = RetrievalMemberForExpression(context, source, item.Value, item.Key, false);
                }
                else if (_RetrievalMemberMethods.TryGetValue(item.Value.ExpressionType, out RetrievalMemberDelegate method1))
                {
                    member = method1(context, source, item.Value, item.Key, false);
                }
                else
                {
                    throw new NotSupportedException(Res.NotSupportedCreateInsertMember);
                }
                if (source.Members.Count != count)
                {
                    source.Members.Add(member);
                }
            }
        }
Ejemplo n.º 2
0
        internal static InsertFragment InsertTemptable(this ContentBase data, TemporaryTableFragment temptable, CommitKeyUnit unit, DbName name = null)
        {
            var members = unit.Keys.Concat(unit.Members).Select(a => a.Metadata);
            var context = data.GenerateContext;
            var table   = new TableFragment(context, unit.Table, name);
            var select  = new SelectFragment(context, temptable);
            var current = new InsertFragment(context, table, select);

            foreach (var member in members)
            {
                select.CreateMember(null, temptable.GetMember(member));
                current.CreateMember(null, member);
            }
            return(current);
        }
Ejemplo n.º 3
0
        public static InsertFragment Insert(this GenerateContext context, ISourceFragment source, TableMetadata target
                                            , IEnumerable <ColumnMetadata> members)
        {
            DbName name = null;

            if (context.Data is ContentBase data)
            {
                name = data.TargetName;
            }
            var table   = new TableFragment(context, target, name);
            var select  = new SelectFragment(context, source);
            var current = new InsertFragment(context, table, select);

            foreach (var member in members)
            {
                select.CreateMember(null, source.GetMember(member));
                current.CreateMember(null, member);
            }
            return(current);
        }