Example #1
0
        public virtual string UpdateQuery(TableDefination table)
        {
            string formattedColumns = string.Join(", ", table.Columns.Select(p => string.Format("[{0}].[{1}] = @{1}", table.TableName, p)));

            return(string.Format(UPDATE_QUERY,
                                 table.TableName,
                                 formattedColumns));
        }
        public virtual string SelectFirstQuery <T>(TableDefination table) where T : BaseEntity
        {
            string formattedColumns = string.Join(",\r\n", table.Columns.Select(p => string.Format("`{0}`", p)));

            return(string.Format(SELECT_FIRST_QUERY,
                                 table.TableName,
                                 formattedColumns));
        }
Example #3
0
        public virtual string InsertQuery(TableDefination table)
        {
            var formattedColumns = table.Columns.Select(p => string.Format("[{0}].[{1}]", table.TableName, p));

            return(string.Format(INSERT_QUERY,
                                 table.TableName,
                                 string.Join(", ", formattedColumns),
                                 string.Join(", @", table.Columns)));
        }
        public virtual string InsertQuery(TableDefination table)
        {
            IEnumerable <string> formattedColumns = table.Columns.Select(p => string.Format("`{0}`", p));

            return(string.Format(INSERT_QUERY,
                                 table.TableName,
                                 string.Join(", ", formattedColumns),
                                 string.Join(", @", table.Columns)));
        }
Example #5
0
        public virtual string SelectFirstQuery <T>(TableDefination table) where T : BaseEntity
        {
            var formattedColumns = table.Columns.Select(p => string.Format("[{0}].[{1}]", table.TableName, p));

            string query = string.Format(SELECT_FIRST_QUERY,
                                         table.TableName,
                                         string.Join(",\r\n", formattedColumns));

            return(query);
        }
Example #6
0
        public virtual string UpdateBulkQuery(TableDefination table)
        {
            IList <string> values  = new List <string>();
            StringBuilder  builder = new StringBuilder();

            for (int i = 0; i < table.EntityCount; i++)
            {
                if (i != 0 && i % 100 == 0)
                {
                    builder.Append("GO\r\n");
                }

                IEnumerable <string> formattedColumns = table.Columns.Select(p => string.Format("[{0}].[{1}] = @{1}{2}", table.TableName, p, i + 1));
                builder.AppendFormat(UPDATE_BULK_QUERY,
                                     table.TableName,
                                     string.Join(", ", formattedColumns));
            }

            return(builder.ToString());
        }
        public virtual string InsertBulkQuery(TableDefination table)
        {
            IList <string> values           = new List <string>();
            StringBuilder  builder          = new StringBuilder();
            string         formattedColumns = string.Join(", ", table.Columns.Select(p => string.Format("`{0}`", p)));

            for (int i = 0; i < table.EntityCount; i++)
            {
                if (i != 0 && i % 100 == 0)
                {
                    builder.Append("GO\r\n");
                }

                string formattedValueColumns = string.Join(", ", table.Columns.Select(p => string.Format("@{0}{1}", p, i + 1)));
                builder.AppendFormat(INSERT_BULK_QUERY,
                                     table.TableName,
                                     formattedColumns,
                                     formattedValueColumns);
            }

            return(builder.ToString());
        }