动态数据站点:无法隐藏表格
我基于“动态数据网站”模板创建了一个新网站。添加了三个表:Product、ProductSKU 和 SkuPrice。表之间存在关系:
Product.ProdId = ProductSku.ProdId
ProductSku.SkuId = SkuPrice.SkuId
我不希望用户看到“Product”表,因此我隐藏了该表:
namespace CompanyDbAdmin
{
[MetadataType(typeof(ProductMetadata))]
public partial class Product
{
}
[ScaffoldTable(false)]
public class ProductMetadata
{
}
}
当我尝试隐藏“ProductSKU”表中的某些列时:
namespace CompanyDbAdmin
{
[MetadataType(typeof(ProductSKUMetadata))]
public partial class ProductSKU
{
}
public class ProductSKUMetadata
{
[ScaffoldColumn(false)]
public object MyCollumnName { get; set; }
}
}
我发现并没有work:该列仍然显示。问题似乎是“ProductSKU”类与现有表不“匹配”...
这是该表的自动生成的代码:
namespace CompanyDbAdmin
{
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[EdmEntityTypeAttribute(NamespaceName="SotiModel", Name="ProductSKU")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class ProductSKU : EntityObject
{
....
}
}
尝试隐藏此表
namespace CompanyDbAdmin
{
[MetadataType(typeof(ProductSKUMetadata))]
public partial class ProductSKU
{
}
[ScaffoldTable(false)]
public class ProductSKUMetadata
{
[ScaffoldColumn(false)]
public object MyCollumnName { get; set; }
}
}
也不起作用:该表仍然存在于第一页上...
为什么?我该如何解决这个问题?
I've created a new web site based on the 'Dynamic Data Site' template. Three tables were added into it: Product, ProductSKU, and SkuPrice. There are relationships between tables:
Product.ProdId = ProductSku.ProdId
ProductSku.SkuId = SkuPrice.SkuId
I don't want the user to see 'Product' table, so I've hidden that table:
namespace CompanyDbAdmin
{
[MetadataType(typeof(ProductMetadata))]
public partial class Product
{
}
[ScaffoldTable(false)]
public class ProductMetadata
{
}
}
When I tried to hide some columns in the 'ProductSKU' table:
namespace CompanyDbAdmin
{
[MetadataType(typeof(ProductSKUMetadata))]
public partial class ProductSKU
{
}
public class ProductSKUMetadata
{
[ScaffoldColumn(false)]
public object MyCollumnName { get; set; }
}
}
I've discovered that didn't work: the column is still displayed. The problem seems like the 'ProductSKU' class is not 'matched' to existing table...
Here is auto-generated code for that table:
namespace CompanyDbAdmin
{
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[EdmEntityTypeAttribute(NamespaceName="SotiModel", Name="ProductSKU")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class ProductSKU : EntityObject
{
....
}
}
Attempt to hide this table with
namespace CompanyDbAdmin
{
[MetadataType(typeof(ProductSKUMetadata))]
public partial class ProductSKU
{
}
[ScaffoldTable(false)]
public class ProductSKUMetadata
{
[ScaffoldColumn(false)]
public object MyCollumnName { get; set; }
}
}
Doesn't work either: The table still exists on the first page...
Why? How can I fix that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该问题的解决方案: 部分类不与自动生成的类部分匹配解决了当前的问题
问题出在 Visual Studio 中:它没有将实体类视为分部类...结果,它没有将元数据类应用于实体类。
The solution to that question: Partial class doesn't match to auto-generated class part resolved the current one either
The problem was in in Visual Studio: it didn't consider the entity class as a partial class... And as a result, it didn't apply metadataclass to the entity class.