Пример #1
0
        private void BuildSingleField(string methodName, string prefix, ITableRegions regions)
        {
            IEnumerable <KeyValuePair <string, string> > names = regions.ReadOrWrites;

            if (buildCast)
            {
                names = names.Where(kv => InCastList(kv.Key));
            }

            if (names.Count() == 0)
            {
                throw new DException("未指定查询字段!");
            }

            names.ForEach((kv, index) =>
            {
                if (index > 0)
                {
                    SQLWriter.Delimiter();
                }

                SQLWriter.Write(methodName);
                SQLWriter.OpenBrace();

                SQLWriter.Name(prefix, kv.Value);

                SQLWriter.CloseBrace();
                SQLWriter.As(kv.Key);
            });
        }
Пример #2
0
        private void BuildColumns(ITableRegions regions)
        {
            string prefix = GetOrAddTablePrefix(regions.TableType);

            if (buildExists && regions.ReadOrWrites.Count > 0)
            {
                regions.ReadOrWrites.ForEach((kv, index) =>
                {
                    if (index > 0)
                    {
                        SQLWriter.Delimiter();
                    }

                    SQLWriter.Name(prefix, kv.Value);

                    if (kv.Key.ToLower() != kv.Value.ToLower())
                    {
                        SQLWriter.As(kv.Key);
                    }
                });
                return;
            }

            IEnumerable <KeyValuePair <string, string> > names = regions.ReadOrWrites;

            if (buildCast)
            {
                names = names.Where(x => InCastList(x.Key));
            }

            if (names.Count() == 0)
            {
                throw new DException("未指定查询字段!");
            }

            names.ForEach((kv, index) =>
            {
                if (index > 0)
                {
                    SQLWriter.Delimiter();
                }

                SQLWriter.Name(prefix, kv.Value);

                if (kv.Key.ToLower() != kv.Value.ToLower())
                {
                    SQLWriter.As(kv.Key);
                }
            });
        }
Пример #3
0
        protected override MemberAssignment VisitMemberAssignment(MemberAssignment node)
        {
            var regions = MakeTableRegions(typeof(T));

            if (regions.ReadWrites.TryGetValue(node.Member.Name, out string value))
            {
                SQLWriter.Name(value);
                SQLWriter.Write("=");

                return(base.VisitMemberAssignment(node));
            }

            throw new ExpressionNotSupportedException($"{node.Member.Name}字段不可写!");
        }