本文整理汇总了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());
}
示例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);
}
示例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);
}
示例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;
}
示例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]);
}
示例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);
}
示例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;
}
示例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());
}
示例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));
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}