EF5如何从DBSET获取模式和表名称
我想编写一个扩展程序,该扩展名应该从DBSET获取表名和模式。
public static string GetTableInfo<T>(this DbSet<T> dbSet) where T : class
{
var tableName = ?? // how to retrieve if from the dbSet ?
var schemaName = ?? // how to retrieve if from the dbSet ?
return $"{schemaName}.{tableName}";
}
用法:
var tableInfo = _libraryContext.Books.GetTableInfo();
// tableInfo should return "dbo.Book"
如何直接从DBSET获取桌子和模式名称?
I want to write an extension that should get the table name and the schema from a dbSet.
public static string GetTableInfo<T>(this DbSet<T> dbSet) where T : class
{
var tableName = ?? // how to retrieve if from the dbSet ?
var schemaName = ?? // how to retrieve if from the dbSet ?
return quot;{schemaName}.{tableName}";
}
Usage :
var tableInfo = _libraryContext.Books.GetTableInfo();
// tableInfo should return "dbo.Book"
how i can get the table and schema names directly from the DbSet ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看是否可以进行以下内容并适应您的代码,因为这是接近但不完全想要的。
在DBContext
扩展方法
示例中
See if you can take the following and adapt to your code as this is close but not exactly what you wanted.
In the dbContext
Extension method
Example