Esempio n. 1
0
        public NoDbSearchItem GetDefaultSearchItem(NoDbTable table, List <NoDbSearchItem> currentItems)
        {
            var defaultItem = new NoDbSearchItem
            {
                RepositoryMethod = "Search" + (currentItems?.Count > 0 ? "_" + currentItems?.Count : "")
            };

            foreach (var column in table.ColumnsWithRelated())
            {
                defaultItem.AllColumns.Add(new NoDbSearchColumn
                {
                    Name            = column.Name,
                    DisplayInCreate = true,
                    DisplayInEdit   = true,
                    DisplayInDetail = true
                });

                defaultItem.DisplayedColumns.Add(new NoDbSearchGridColumn
                {
                    ColumnName = column.Name
                });

                if (NoDbHelper.IsDate(column.DataType))
                {
                    defaultItem.Columns.Add(new NoDbSearchFilterColumn
                    {
                        ColumnName = column.Name,
                        Title      = column.Name + ">",
                        Sign       = NoDbSearchSign.Greater
                    });
                    defaultItem.Columns.Add(new NoDbSearchFilterColumn
                    {
                        ColumnName = column.Name,
                        Title      = column.Name + "<=",
                        Sign       = NoDbSearchSign.LessEq
                    });
                    continue;
                }

                if (column.DataType == NoDbDataType.STRING)
                {
                    defaultItem.Columns.Add(new NoDbSearchFilterColumn
                    {
                        ColumnName = column.Name,
                        Sign       = NoDbSearchSign.Contain
                    });
                    continue;
                }
                defaultItem.Columns.Add(new NoDbSearchFilterColumn
                {
                    ColumnName = column.Name,
                    Sign       = NoDbSearchSign.Equal
                });
            }

            return(defaultItem);
        }
Esempio n. 2
0
        public override string CreateTableQuery(NoDbTable table)
        {
            string        schema        = GetSchema(table);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendFormat("CREATE TABLE {1}.{0}(\n", Escape(table.Detail.GetTableDbName()), schema);

            stringBuilder.AppendFormat("\t{0}\n", string.Join(",\n\t", table.ColumnsWithRelated().Select(x => ColumnQuery(x))));

            stringBuilder.Append("\n);\n");
            foreach (var item in table.Indices)
            {
                stringBuilder.Append(CreateIndexQuery(table, item) + "\n");
            }
            foreach (var item in table.Relations)
            {
                stringBuilder.Append(CreateRelationQuery(table, item));
            }
            return(stringBuilder.ToString());
        }