具有自己的元数据的 asp.net 动态数据站点
我正在搜索有关在 asp.NET 动态站点中配置自己的元数据的信息。
例如。我在 MS Sql Server 中有一个表,其结构如下所示:
CREATE TABLE [dbo].[someTable](
[id] [int] NOT NULL,
[pname] [nvarchar](20) NULL,
[FullName] [nvarchar](50) NULL,
[age] [int] NULL)
我有 2 个 Ms Sql 表(我已创建),sysTables 和 sysColumns。
sysTables:
ID sysTableName TableName TableDescription
1 | someTable |Persons |系统中有关人员的所有数据
sysColumns:
ID TableName sysColumnName ColumnName ColumnDesc ColumnType MUnit
1 |someTable |某个表名|名称 |角色名称(例如约翰)| nvarchar(20) |空
2 |一些表| sometable_全名|全名 |角色名称(例如约翰·布莱克)| nvarchar(50) |空
3 |一些表|某个表的年龄|年龄 |人物年龄|整数 | null
我希望在 Details/Edit/Insert/List/ListDetails 页面中用作元数据 sysColumns 和 sysTableData。因为,对于前。在详细信息页面 fullName 中,它不如 Full Name 漂亮。
有些想法,可能吗?
谢谢
更新:: 在列表页面中显示来自 sysTables(元数据表)的数据,我修改了
。<%= tableName%>
public string tableName;
protected void Page_Init(object sender, EventArgs e)
{
table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
//added by me
uqsikDataContext sd=new uqsikDataContext();
tableName = sd.sysTables.Where(n => n.sysTableName == table.DisplayName).FirstOrDefault().TableName;
//end
GridView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));
GridDataSource.EntityTypeName = table.EntityType.AssemblyQualifiedName;
if (table.EntityType != table.RootEntityType)
{
GridQueryExtender.Expressions.Add(new OfTypeExpression(table.EntityType));
}
}
那么 sysColums 呢?如何从我的 sysColumns 表中获取数据?
I'm searching info about configuring own MetaData in asp.NET Dynamic Site.
For example. I have a table in MS Sql Server with structure shown below:
CREATE TABLE [dbo].[someTable](
[id] [int] NOT NULL,
[pname] [nvarchar](20) NULL,
[FullName] [nvarchar](50) NULL,
[age] [int] NULL)
and I there are 2 Ms Sql tables (I've created), sysTables and sysColumns.
sysTables:
ID sysTableName TableName TableDescription
1 | someTable |Persons |All Data about Persons in system
sysColumns:
ID TableName sysColumnName ColumnName ColumnDesc ColumnType MUnit
1 |someTable | sometable_pname| Name | Persona Name(ex. John)| nvarchar(20) | null
2 |someTable | sometable_Fullname| Full Name | Persona Name(ex. John Black)| nvarchar(50) | null
3 |someTable | sometable_age| age | Person age| int | null
I want that, in Details/Edit/Insert/List/ListDetails pages use as MetaData sysColumns and sysTableData. Because, for ex. in DetailsPage fullName, it is not beatiful as Full Name .
someIdea, is it possible?
thanks
Updated::
In List Page to display data from sysTables (metaData table) I've modified <h2 class="DDSubHeader"><%= tableName%></h2>
.
public string tableName;
protected void Page_Init(object sender, EventArgs e)
{
table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
//added by me
uqsikDataContext sd=new uqsikDataContext();
tableName = sd.sysTables.Where(n => n.sysTableName == table.DisplayName).FirstOrDefault().TableName;
//end
GridView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));
GridDataSource.EntityTypeName = table.EntityType.AssemblyQualifiedName;
if (table.EntityType != table.RootEntityType)
{
GridQueryExtender.Expressions.Add(new OfTypeExpression(table.EntityType));
}
}
so, what about sysColums? How can I get Data from my sysColumns table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
总之,是的,这是可能的。然而,我不认为这是一个好主意。您真正谈论的是在数据库中存储演示数据,而实际上放置这些数据的最佳位置是在您的 aspx 页面本身中。话虽这么说,如果您想在数据库中存储数据字典类型信息,我建议使用内置的 sys.tables、sys.columns 和MS SQL Server 中内置的
sys.types
视图,并添加一个名为ObjectDescriptions
的表来存储显示名称和类型。然后,您可以根据对象 ID 创建一个视图来检索表的元数据,并直接绑定或动态填充您的 asp.net
FormView
。编辑:
然后,您可以在 ASP 代码中利用此视图,方法是编写一个保存有关单个表的元数据的类,并在 DAL 中编写一个方法来根据对象或表名称检索此类的实例。当您填充页面时,页面可以检索您正在查找的记录以及表的元数据,并将该元数据绑定到网格标题(在列表视图中)或单个标签的随附文本框。记录模式。
In a word, yes, it is possible. However, I do not believe this is a good idea. What you are really talking about is storing presentation data in your database, when really the best place to put this is in your aspx pages themselves. That being said, if you want to store data dictionary type information in your DB, I'd recommend making use of the built in
sys.tables
,sys.columns
, andsys.types
views that are built into MS SQL Server, and adding a table calledObjectDescriptions
to store the display name and type.Then, you could create a view based on object ID to retrieve the meta data of your table, and either directly bind or dynamically populate your asp.net
FormView
.EDIT:
You can then leverage this view in your ASP code by writing a class that holds your meta data about a single table, and writing a method in your DAL to retrieve an instance of this class based on object or table name. When you populate your page, the page could retrieve both the record you are looking for, as well as the table's meta-data, and bind that meta data to either grid headers (in list view) or to individual label's accompanying text boxes in single record mode.
我发现有用的文章,可以用来解决我的问题
I've found useful article, than can be used for solution my problem