当前位置: 首页>>代码示例>>C#>>正文


C# SqlTable类代码示例

本文整理汇总了C#中SqlTable的典型用法代码示例。如果您正苦于以下问题:C# SqlTable类的具体用法?C# SqlTable怎么用?C# SqlTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SqlTable类属于命名空间,在下文中一共展示了SqlTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetTable

		public virtual void SetTable(SqlTable table, MemberInfo member, IEnumerable<Expression> arguments, IEnumerable<ISqlExpression> sqlArgs)
		{
			table.SqlTableType   = SqlTableType.Function;
			table.Name           = Name ?? member.Name;
			table.PhysicalName   = Name ?? member.Name;
			table.TableArguments = ConvertArgs(member, sqlArgs.ToArray());
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:7,代码来源:TableFunctionAttribute.cs

示例2: GetIdentityExpression

		public override ISqlExpression GetIdentityExpression(SqlTable table)
		{
			if (!table.SequenceAttributes.IsNullOrEmpty())
				return new SqlExpression("GEN_ID(" + table.SequenceAttributes[0].SequenceName + ", 1)", Precedence.Primary);

			return base.GetIdentityExpression(table);
		}
开发者ID:donners77,项目名称:linq2db,代码行数:7,代码来源:FirebirdSqlBuilder.cs

示例3: GetIdentityExpression

		public override ISqlExpression GetIdentityExpression(SqlTable table, SqlField identityField, bool forReturning)
		{
			if (table.SequenceAttributes != null)
				return new SqlExpression("GEN_ID(" + table.SequenceAttributes[0].SequenceName + ", 1)", Precedence.Primary);

			return base.GetIdentityExpression(table, identityField, forReturning);
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:7,代码来源:FirebirdSqlProvider.cs

示例4: getTableFromRawSql

        public static SqlTable getTableFromRawSql(string rawSql)
        {
            SqlTable sqlTable = new SqlTable();
            using (SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["BROWSitContext"].ConnectionString))
            {
                using (SqlDataAdapter adapter = new SqlDataAdapter(rawSql, connection))
                {
                    try
                    {
                        adapter.Fill(sqlTable.contents);
                    }
                    catch (SqlException e)
                    {
                        //sqlTable.errors = e.Errors;
                        foreach (SqlError se in e.Errors)
                        {
                            sqlTable.errorStrings.Add("Message: " + se.Message
                                + " | Number: " + se.Number
                                + " | Line: " + se.LineNumber
                                + " | Source: " + se.Source
                                + " | Procedure: " + se.Procedure);
                        }
                    }
                }
            }

            return sqlTable;
        }
开发者ID:takajimy,项目名称:BrowsIt-NewerButStillOld,代码行数:28,代码来源:SqlHelper.cs

示例5: Ctor_WithTableName_SetsTableNameProperty

        public void Ctor_WithTableName_SetsTableNameProperty()
        {
            var table = new SqlTable("[dbo].[Users]");

            Assert.NotNull(table.TableName);
            Assert.Equal("dbo", table.TableName.Segments[0]);
            Assert.Equal("Users", table.TableName.Segments[1]);
        }
开发者ID:WouterDemuynck,项目名称:popsql,代码行数:8,代码来源:SqlTableTests.cs

示例6: ExpressionType_ReturnsJoin

        public void ExpressionType_ReturnsJoin()
        {
            var table = new SqlTable("dbo.Users", "u");
            var predicate = SqlExpression.Equal("u.Id", 5);
            var expression = new SqlJoin(SqlJoinType.Left, table);

            Assert.Equal(SqlExpressionType.Join, expression.ExpressionType);
        }
开发者ID:WouterDemuynck,项目名称:popsql,代码行数:8,代码来源:SqlJoinTests.cs

示例7: SetTable

			public override void SetTable(MappingSchema mappingSchema, SqlTable table, MemberInfo member, IEnumerable<Expression> arguments, IEnumerable<ISqlExpression> sqlArgs)
			{
				table.SqlTableType   = SqlTableType.Expression;
				table.Name           = Expression ?? member.Name;
				table.TableArguments = ConvertArgs(member, sqlArgs.ToArray());

				if (Schema   != null) table.Owner    = Schema;
				if (Database != null) table.Database = Database;
			}
开发者ID:donners77,项目名称:linq2db,代码行数:9,代码来源:Sql.TableExpressionAttribute.cs

示例8: ImplicitConversion_WithAlias_ReturnsColumn

        public void ImplicitConversion_WithAlias_ReturnsColumn()
        {
            var table = new SqlTable("[dbo].[Users]", "u");
            var column = table + "Id";

            Assert.NotNull(column);
            Assert.Equal(2, column.ColumnName.Segments.Length);
            Assert.Equal("u", column.ColumnName.Segments.First());
            Assert.Equal("Id", column.ColumnName.Segments.Last());
        }
开发者ID:WouterDemuynck,项目名称:popsql,代码行数:10,代码来源:SqlTableTests.cs

示例9: Test

        public void Test()
        {
            var schema = new MappingSchema();
            schema.SetDataType(typeof (decimal), new SqlDataType(DataType.Decimal, 19, 4));

            var table = new SqlTable<Foo>(schema);

            Assert.That(table.Fields.Single().Value.Precision, Is.EqualTo(19));
            Assert.That(table.Fields.Single().Value.Scale, Is.EqualTo(4));
        }
开发者ID:ili,项目名称:linq2db,代码行数:10,代码来源:CreateDecimalTableColumnTests.cs

示例10: GetIdentityExpression

        public override ISqlExpression GetIdentityExpression(SqlTable table)
        {
            if (!table.SequenceAttributes.IsNullOrEmpty())
            {
                var attr = GetSequenceNameAttribute(table, false);

                if (attr != null)
                    return new SqlExpression(attr.SequenceName + ".nextval", Precedence.Primary);
            }

            return base.GetIdentityExpression(table);
        }
开发者ID:pebezo,项目名称:linq2db,代码行数:12,代码来源:OracleSqlBuilder.cs

示例11: SetTable

        public override void SetTable(SqlTable table, MemberInfo member, IEnumerable<Expression> expArgs, IEnumerable<ISqlExpression> sqlArgs)
        {
            var aargs  = sqlArgs.ToArray();
            var arr    = ConvertArgs(member, aargs).ToList();
            var method = (MethodInfo)member;

            {
                var ttype  = method.GetGenericArguments()[0];
                var tbl    = new SqlTable(ttype);

                var database     = Convert(tbl.Database);
                var owner        = Convert(tbl.Owner);
                var physicalName = Convert(tbl.PhysicalName);

                var name = "";

                if (database != null)
                    name = database + "." + (owner == null ? "." : owner + ".");
                else if (owner != null)
                    name = owner + ".";

                name += physicalName;

                arr.Add(new SqlExpression(name, Precedence.Primary));
            }

            {
                var field = ((ConstantExpression)expArgs.First()).Value;

                if (field is string)
                {
                    arr[0] = new SqlExpression(field.ToString(), Precedence.Primary);
                }
                else if (field is LambdaExpression)
                {
                    var body = ((LambdaExpression)field).Body;

                    if (body is MemberExpression)
                    {
                        var name = ((MemberExpression)body).Member.Name;

                        if (name.Length > 0 && name[0] != '[')
                            name = "[" + name + "]";

                        arr[0] = new SqlExpression(name, Precedence.Primary);
                    }
                }
            }

            table.SqlTableType   = SqlTableType.Expression;
            table.Name           = "FREETEXTTABLE({6}, {2}, {3}) {1}";
            table.TableArguments = arr.ToArray();
        }
开发者ID:pebezo,项目名称:linq2db,代码行数:53,代码来源:FreeTextTableExpressionAttribute.cs

示例12: GetIdentityExpression

		public override ISqlExpression GetIdentityExpression(SqlTable table, SqlField identityField, bool forReturning)
		{
			if (table.SequenceAttributes != null)
			{
				var attr = GetSequenceNameAttribute(table, false);

				if (attr != null)
					return new SqlExpression(attr.SequenceName + ".nextval", Precedence.Primary);
			}

			return base.GetIdentityExpression(table, identityField, forReturning);
		}
开发者ID:ivanoffalex,项目名称:bltoolkit,代码行数:12,代码来源:OracleSqlProvider.cs

示例13: Union_WithRealLifeQuery_ReturnsQuery

        public void Union_WithRealLifeQuery_ReturnsQuery()
        {
            SqlTable suppliers = new SqlTable("Supplier", "s");
            SqlTable customers = new SqlTable("Customer", "c");
            var actual = Sql
                .Union(
                    Sql.Select(suppliers + "City").From(suppliers),
                    Sql.Select(customers + "City").From(customers))
                .ToSql();

            const string expected = "(SELECT [s].[City] FROM [Supplier] [s]) UNION (SELECT [c].[City] FROM [Customer] [c])";
            Assert.Equal(expected, actual);
        }
开发者ID:WouterDemuynck,项目名称:popsql,代码行数:13,代码来源:SqlTests.cs

示例14: Ctor_WithTableAndPredicate_SetsPropertyValues

        public void Ctor_WithTableAndPredicate_SetsPropertyValues()
        {
            var table = new SqlTable("dbo.Users", "u");
            var predicate = SqlExpression.Equal("u.Id", 5);
            var expression = new SqlJoin(SqlJoinType.Left, table, predicate);

            Assert.NotNull(expression.Table);
            Assert.Same(table, expression.Table);
            Assert.NotNull(expression.On);
            Assert.NotNull(expression.On.Predicate);
            Assert.Same(predicate, expression.On.Predicate);
            Assert.Equal(SqlJoinType.Left, expression.Type);
        }
开发者ID:WouterDemuynck,项目名称:popsql,代码行数:13,代码来源:SqlJoinTests.cs

示例15: Select_WithGroupByWithRealLifeQuery_ReturnsQuery

        public void Select_WithGroupByWithRealLifeQuery_ReturnsQuery()
        {
            SqlTable profiles = new SqlTable("Profile", "p");
            var actual = Sql
                .Select(profiles + "Age", SqlAggregate.Count(profiles + "Id", "Count"))
                .From(profiles)
                .GroupBy(profiles + "Age")
                .Having(SqlExpression.GreaterThanOrEqual(profiles + "Age", 18))
                .ToSql();

            const string expected = "SELECT [p].[Age], COUNT([p].[Id]) AS [Count] FROM [Profile] [p] GROUP BY ([p].[Age]) HAVING [p].[Age] >= 18";
            Assert.Equal(expected, actual);
        }
开发者ID:WouterDemuynck,项目名称:popsql,代码行数:13,代码来源:SqlTests.cs


注:本文中的SqlTable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。