public static void MusicItemsTable(IdbMigration db)
        {
            var t = new TableMigration
            {
                HasIdentity = true,
                TableName   = xmConsts.MusicItems
            };

            t.Fields = new List <TableMigrationField>();
            t.Fields.Add(new TableMigrationField {
                FieldName = "Artist", FieldType = TableMigrationFieldType.Varchar, FieldLLenght = 5000, IsNullAble = true
            });
            t.Fields.Add(new TableMigrationField {
                FieldName = "FullFileName", FieldType = TableMigrationFieldType.Varchar, FieldLLenght = 5000, IsNullAble = true
            });
            t.Fields.Add(new TableMigrationField {
                FieldName = "FileName", FieldType = TableMigrationFieldType.Varchar, FieldLLenght = 5000, IsNullAble = true
            });
            t.Fields.Add(new TableMigrationField {
                FieldName = "Title", FieldType = TableMigrationFieldType.Varchar, FieldLLenght = 5000, IsNullAble = true
            });
            t.Fields.Add(new TableMigrationField {
                FieldName = "MachineName", FieldType = TableMigrationFieldType.Varchar, FieldLLenght = 5000, IsNullAble = true
            });

            //t.Fields.Add(new TableMigrationField { FieldName = "ToUsb", FieldType = TableMigrationFieldType.Bit,  IsNullAble = true });
            //t.Fields.Add(new TableMigrationField { FieldName = "ToPlaylist", FieldType = TableMigrationFieldType.Bit, IsNullAble = true });
            db.ExecurteCreateTable(t.ToString());
        }
示例#2
0
        private static void InitGenericTables()
        {
            try
            {
                var subclassTypes = Assembly.GetAssembly(typeof(GenericData)).GetTypes().Where(t => t.IsSubclassOf(typeof(GenericData)));
                var names         = subclassTypes.Select(x => x.Name).ToList();
                foreach (var genericItem in subclassTypes)
                {
                    if (!_DBr.DbMigration.CheckTableExistence(genericItem.Name))
                    {
                        var t = new TableMigration
                        {
                            HasIdentity = true,
                            TableName   = genericItem.Name
                        };
                        t.Fields = new List <TableMigrationField>();

                        t.Fields.Add(new TableMigrationField {
                            FieldName = "Description", FieldType = TableMigrationFieldType.NVarchar, FieldLLenght = 500, IsNullAble = true
                        });
                        t.Fields.Add(new TableMigrationField {
                            FieldName = "CreationDate", FieldType = TableMigrationFieldType.Date
                        });
                        t.Fields.Add(new TableMigrationField {
                            FieldName = "UpdateDate", FieldType = TableMigrationFieldType.Date
                        });
                        t.Fields.Add(new TableMigrationField {
                            FieldName = "Active", FieldType = TableMigrationFieldType.Bit
                        });

                        var properties = genericItem.GetProperties();
                        foreach (var propertyInfo in properties)
                        {
                            var genericDataField = ((GenericDataFieldAttribute[])propertyInfo.GetCustomAttributes(typeof(GenericDataFieldAttribute), true)).FirstOrDefault();
                            if (genericDataField.NotNull())
                            {
                                t.Fields.Add(new TableMigrationField
                                {
                                    FieldName    = genericDataField.FieldName,
                                    FieldType    = TableMigrationFieldType.NVarchar,
                                    FieldLLenght = 500,
                                    IsNullAble   = true
                                });
                            }
                        }

                        _DBr.DbMigration.ExecurteCreateTable(t.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                string exx = ex.Message;
            }
        }
        public static void UserPlaylistsTable(IdbMigration db)
        {
            var t = new TableMigration
            {
                HasIdentity = true,
                TableName   = xmConsts.UserPlayList
            };

            t.Fields = new List <TableMigrationField>();
            t.Fields.Add(new TableMigrationField {
                FieldName = "UserId", FieldType = TableMigrationFieldType.Integer, IsNullAble = true
            });
            t.Fields.Add(new TableMigrationField {
                FieldName = "ItemId", FieldType = TableMigrationFieldType.Integer, IsNullAble = true
            });

            db.ExecurteCreateTable(t.ToString());
        }
        public static void UsersTable(IdbMigration db)
        {
            var t = new TableMigration
            {
                HasIdentity = true,
                TableName   = xmConsts.Users
            };

            t.Fields = new List <TableMigrationField>();
            t.Fields.Add(new TableMigrationField {
                FieldName = "UserName", FieldType = TableMigrationFieldType.Varchar, FieldLLenght = 5000, IsNullAble = true
            });
            t.Fields.Add(new TableMigrationField {
                FieldName = "Password", FieldType = TableMigrationFieldType.Varchar, FieldLLenght = 5000, IsNullAble = true
            });

            db.ExecurteCreateTable(t.ToString());
        }
        //public static void T3(IDbMigration db)
        //{
        //    //var t = new TableMigration
        //    //{
        //    //    HasIdentity = true,
        //    //    TableName = "testmigration3"
        //    //};
        //    //t.Fields = new List<TableMigrationField>();
        //    //t.Fields.Add(new TableMigrationField { FieldName = "col1", FieldType = TableMigrationFieldType.Integer, IsNullAble = false });
        //    //t.Fields.Add(new TableMigrationField { FieldName = "col2", FieldType = TableMigrationFieldType.Decimal, IsNullAble = true });
        //    //t.Fields.Add(new TableMigrationField { FieldName = "col3", FieldType = TableMigrationFieldType.Date, IsNullAble = true });
        //    //t.Fields.Add(new TableMigrationField { FieldName = "col4", FieldType = TableMigrationFieldType.Text, IsNullAble = true });
        //    //t.Fields.Add(new TableMigrationField { FieldName = "col5", FieldType = TableMigrationFieldType.Varchar, FieldLLenght = 500, IsNullAble = true });

        //    //db.ExecurteCreateTable(t.ToString());
        //}

        public static void MigrationTable(IdbMigration db)
        {
            var t = new TableMigration
            {
                HasIdentity = true,
                TableName   = "migItems"
            };

            t.Fields = new List <TableMigrationField>();
            t.Fields.Add(new TableMigrationField {
                FieldName = "Name", FieldType = TableMigrationFieldType.Varchar, FieldLLenght = 5000, IsNullAble = true
            });
            t.Fields.Add(new TableMigrationField {
                FieldName = "Date", FieldType = TableMigrationFieldType.Date, IsNullAble = true
            });

            db.ExecurteCreateTable(t.ToString());
        }