Ejemplo n.º 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);
            });
        }
Ejemplo n.º 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);
                }
            });
        }