本文整理汇总了C#中IQuery.CreateView方法的典型用法代码示例。如果您正苦于以下问题:C# IQuery.CreateView方法的具体用法?C# IQuery.CreateView怎么用?C# IQuery.CreateView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQuery
的用法示例。
在下文中一共展示了IQuery.CreateView方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTestView
private static void CreateTestView(IQuery query)
{
var tn1 = ObjectName.Parse("APP.test_table1");
query.Access().CreateTable(table => table
.Named(tn1)
.WithColumn("id", PrimitiveTypes.Integer())
.WithColumn("name", PrimitiveTypes.String())
.WithColumn("date", PrimitiveTypes.DateTime()));
query.Session.Access().AddPrimaryKey(tn1, "id");
var exp = SqlExpression.Parse("SELECT * FROM APP.test_table1");
query.CreateView(ObjectName.Parse("APP.test_view1"), (SqlQueryExpression)exp);
}
示例2: Create
internal static void Create(IQuery systemQuery)
{
if (systemQuery.Access().HasSecurity) {
// This view shows the grants that the user has (no join, only priv_bit).
systemQuery.CreateView(ThisUserSimpleGrantViewName, query => query
.Column("priv_bit")
.Column("object")
.Column("name")
.Column("grantee")
.Column("grant_option")
.Column("granter")
.FromTable(SystemSchema.GrantsTableName)
.Where(where => where.Reference("grantee").Equal(right => right.Function("user"))
.Or(or => or.Reference("grantee").Equal(right => right.Value(User.PublicName)))));
// This view shows the grants that the user is allowed to see
// CREATE VIEW ThisUserGrant AS
// SELECT i_privilege_string(priv_bit) AS description, object, name, grantee, grant_option, granter
// FROM grants
// WHERE (grantee = user() OR grantee = 'PUBLIC')
systemQuery.CreateView(ThisUserGrantViewName, query => query
.Function("i_privilege_string", new SqlExpression[] {
SqlExpression.Reference(new ObjectName("priv_bit"))
}, "description")
.Column("object")
.Column("name")
.Column("grantee")
.Column("grant_option")
.Column("granter")
.FromTable(SystemSchema.GrantsTableName)
.Where(where => where.Reference("grantee").Equal(right => right.Function("user"))
.Or(or => or.Reference("grantee").Equal(right => right.Value(User.PublicName)))));
// A view that represents the list of schema this user is allowed to view
// the contents of.
// CREATE VIEW ThisUserSchemaInfo AS
// SELECT * FROM SYSTEM.schema_info
// WHERE name IN (
// SELECT name
// FROM INFORMATION_SCHEMA.ThisUserGrant
// WHERE object = 1 AND description LIKE '%LIST%')
systemQuery.CreateView(ThisUserSchemaInfoViewName, query => query
.AllColumns()
.FromTable(SystemSchema.SchemaInfoTableName)
.Where(where => where
.Reference("name")
.In(@in => @in
.Query(sub => sub
.Column("name")
.FromTable(ThisUserGrantViewName)
.Where(filter => filter
.Reference("object").Equal(value => value.Value((int)DbObjectType.Schema))
.And(and => and
.Reference("description")
.Like(String.Format("%{0}%", Privileges.List.ToString().ToUpperInvariant()))))))));
// A view that exposes the table_columns table but only for the tables
// this user has read access to.
// CREATE VIEW INFORMATION_SCHEMA.ThisUserTableColumns AS
// SELECT * FROM SYSTEM.table_columns
// WHERE schema IN (
// SELECT name FROM INFORMATION_SCHEMA.ThisUserSchemaInfo)
systemQuery.CreateView(ThisUserTableColumnsViewName, query => query
.AllColumns()
.FromTable(SystemSchema.TableColumnsTableName)
.Where(where => where
.Reference("schema")
.In(@in => @in
.Query(sub => sub
.Column("name")
.FromTable(ThisUserSchemaInfoViewName)))));
// A view that exposes the 'table_info' table but only for the tables
// this user has read access to.
// CREATE VIEW INFORMATION_SCHEMA.ThisUserTableInfo AS
// SELECT * FROM SYSTEM.table_info
// WHERE schema IN (
// SELECT name FROM INFORMATION_SCHEMA.ThisUserSchemaInfo)
systemQuery.CreateView(ThisUserTableInfoViewName, query => query
.AllColumns()
.FromTable(SystemSchema.TableInfoTableName)
.Where(where => where
.Reference("schema")
.In(@in => @in
.Query(sub => sub
.Column("name")
.FromTable(ThisUserSchemaInfoViewName)))));
// CREATE VIEW INFORMATION_SCHEMA.Tables AS
// SELECT NULL AS TABLE_CATALOG,
// schema AS TABLE_SCHEMA,
// name AS TABLE_NAME
// type AS TABLE_TYPE,
//.........这里部分代码省略.........