protected override SqlStatement PrepareStatement(IRequest context)
        {
            var schemaName = context.Access().ResolveSchemaName(TypeName.ParentName);
            var typeName   = new ObjectName(schemaName, TypeName.Name);

            var statement = new CreateTypeStatement(typeName, Members, ReplaceIfExists)
            {
                IsSealed   = IsSealed,
                IsAbstract = IsAbstract
            };

            var parentName = ParentTypeName;

            if (parentName != null)
            {
                parentName = context.Access().ResolveObjectName(DbObjectType.Type, parentName);
            }

            statement.ParentTypeName = parentName;

            return(statement);
        }
示例#2
0
        protected override SqlStatement PrepareStatement(IRequest context)
        {
            var schemaName = context.Access().ResolveSchemaName(TypeName.ParentName);
            var typeName = new ObjectName(schemaName, TypeName.Name);

            var statement = new CreateTypeStatement(typeName, Members, ReplaceIfExists) {
                IsSealed = IsSealed,
                IsAbstract = IsAbstract
            };

            var parentName = ParentTypeName;
            if (parentName != null) {
                parentName = context.Access().ResolveObjectName(DbObjectType.Type, parentName);
            }

            statement.ParentTypeName = parentName;

            return statement;
        }
        public void CreateSimpleType()
        {
            var typeName = ObjectName.Parse("APP.type1");
            var members = new UserTypeMember[] {
                new UserTypeMember("id", PrimitiveTypes.Integer()),
                new UserTypeMember("name", PrimitiveTypes.VarChar())
            };

            var statement = new CreateTypeStatement(typeName, members);

            SerializeAndAssert(statement, (serialized, deserialized) => {
                Assert.IsNotNull(deserialized);
                Assert.IsNotNull(deserialized.TypeName);
                Assert.AreEqual(typeName, deserialized.TypeName);
                Assert.IsNotNull(deserialized.Members);
                Assert.IsNotEmpty(deserialized.Members);
                Assert.AreEqual(2, deserialized.Members.Length);
            });
        }