Beispiel #1
0
        public static bool EqualsName(this ObjectIdentifier source, SchemaObjectName target)
        {
            if (target.SchemaIdentifier == null)
            {
                return(Quote.Name(source.GetName()) == Quote.Name(target.BaseIdentifier.Value));
            }

            return(Quote.Name(source.GetSchema()) == Quote.Name(target.SchemaIdentifier.Value) &&
                   Quote.Name(source.GetName()) == Quote.Name(target.BaseIdentifier.Value));
        }
Beispiel #2
0
        private void CreateFakeTableDefinition(ObjectIdentifier table)
        {
            var fakeTable = new ExecuteStatement();

            fakeTable.ExecuteSpecification = new ExecuteSpecification();

            var procedureReference = new ProcedureReference();

            procedureReference.Name = new SchemaObjectName();
            procedureReference.Name.Identifiers.Add("tSQLt".ToIdentifier());
            procedureReference.Name.Identifiers.Add("FakeTable".ToIdentifier());

            var entity = new ExecutableProcedureReference();

            entity.ProcedureReference = new ProcedureReferenceName();
            entity.ProcedureReference.ProcedureReference = procedureReference;

            entity.Parameters.Add(
                ParametersHelper.CreateStoredProcedureParameter(string.Format("{0}", table.GetSchema())));
            entity.Parameters.Add(
                ParametersHelper.CreateStoredProcedureParameter(string.Format("{0}", table.GetName())));

            fakeTable.ExecuteSpecification.ExecutableEntity = entity;

            _testProcedure.StatementList.Statements.Add(fakeTable);
        }
Beispiel #3
0
        public static SchemaObjectName ToSchemaObjectName(this ObjectIdentifier source)
        {
            var target = new SchemaObjectName();

            target.Identifiers.Add(source.GetSchema().ToScriptDomIdentifier().Quote());
            target.Identifiers.Add(source.GetName().ToScriptDomIdentifier().Quote());

            return(target);
        }
Beispiel #4
0
        public static Identifier ToIdentifier(this ObjectIdentifier source)
        {
            var name = source.GetName();

            return(new Identifier
            {
                Value = name.Quote()
            });
        }
Beispiel #5
0
        public static LiteralType GetLiteralType(ObjectIdentifier name)
        {

            switch (name.GetName())
            {
                case "bigint":
                case "smallint":
                case "tinyint":
                case "int":
                case "bit":
                    return LiteralType.Integer;

                case "numeric":
                case "decimal":
                case "float":
                case "real":
                    return LiteralType.Numeric;


                case "money":
                case "smallmoney":
                    return LiteralType.Money;

                case "date":
                case "datetimeoffset":
                case "datetime2":
                case "smalldatetime":
                case "datetime":
                case "time":
                case "char":
                case "varchar":
                case "text":
                case "nchar":
                case "nvarchar":
                case "ntext":
                case "timestamp":
                case "uniqueidentifier":
                case "sql_variant":
                case "xml":

                    return LiteralType.String;

                case "binary":
                case "varbinary":
                case "image":
                    return LiteralType.Binary;

            }


            return LiteralType.String;
        }
        public static bool IsNText(ObjectIdentifier name)
        {
            switch (name.GetName())
            {
            case "nchar":
            case "nvarchar":
            case "ntext":
            case "xml":
                return(true);
            }

            return(false);
        }
Beispiel #7
0
        public static bool IsNText(ObjectIdentifier name)
        {
            switch (name.GetName())
            {
                case "nchar":
                case "nvarchar":
                case "ntext":
                case "xml":
                    return true;
            }

            return false;
        }
        public static LiteralType GetLiteralType(ObjectIdentifier name)
        {
            switch (name.GetName())
            {
            case "bigint":
            case "smallint":
            case "tinyint":
            case "int":
            case "bit":
                return(LiteralType.Integer);

            case "numeric":
            case "decimal":
            case "float":
            case "real":
                return(LiteralType.Numeric);


            case "money":
            case "smallmoney":
                return(LiteralType.Money);

            case "date":
            case "datetimeoffset":
            case "datetime2":
            case "smalldatetime":
            case "datetime":
            case "time":
            case "char":
            case "varchar":
            case "text":
            case "nchar":
            case "nvarchar":
            case "ntext":
            case "timestamp":
            case "uniqueidentifier":
            case "sql_variant":
            case "xml":

                return(LiteralType.String);

            case "binary":
            case "varbinary":
            case "image":
                return(LiteralType.Binary);
            }


            return(LiteralType.String);
        }
Beispiel #9
0
 public static string GetSchemaObjectName(this ObjectIdentifier name)
 {
     return(string.Format("{0}.{1}", name.GetSchema(), name.GetName()));
 }
Beispiel #10
0
        private void CreateFakeTableDefinition(ObjectIdentifier table)
        {
            var fakeTable = new ExecuteStatement();
            fakeTable.ExecuteSpecification = new ExecuteSpecification();

            var procedureReference = new ProcedureReference();
            procedureReference.Name = new SchemaObjectName();
            procedureReference.Name.Identifiers.Add("tSQLt".ToIdentifier());
            procedureReference.Name.Identifiers.Add("FakeTable".ToIdentifier());

            var entity = new ExecutableProcedureReference();
            entity.ProcedureReference = new ProcedureReferenceName();
            entity.ProcedureReference.ProcedureReference = procedureReference;

            entity.Parameters.Add(
                ParametersHelper.CreateStoredProcedureParameter(string.Format("{0}", table.GetSchema())));
            entity.Parameters.Add(
                ParametersHelper.CreateStoredProcedureParameter(string.Format("{0}", table.GetName())));

            fakeTable.ExecuteSpecification.ExecutableEntity = entity;

            _testProcedure.StatementList.Statements.Add(fakeTable);
        }