动态数据实体ID列可见假的?实体、动态、数据、ID

2023-09-03 08:16:14 作者:扑倒i

有两种模板在asp.net 3.5

There are Two kind of template in asp.net 3.5

1)动态数据Web应用程序。

1) Dynamic Data Web App.

2)动态数据Web应用程序。实体

2) Dynamic Data Web App. Entities

我的SQL数据库得到了客户表;列:ID,姓名,姓VS

My SQL database has got Customer Table ; Columns : ID, Name,Surname vs.

如果你使用的第一个(动态数据Web应用程序);你无法看到ID列(Customer表)(LINQ到SQL)

if you use first one(Dynamic Data Web App); you can not see ID column(Customer Table) (Linq to Sql)

但是,如果你使用第二个(动态数据Web应用程序,实体),你可以看到ID列

But if you use second one(Dynamic Data Web App. Entities), you can see ID column

如何过滤柱尤其ID区域。我是说;我需要ID列的visible = false

How can i filter column especially ID area. I mean; i need ID column visible =false

推荐答案

在你的元数据类,将ID设置为以下内容:

In your metadata class, set the Id to the following:

[ScaffoldColumn(false)]
public object Id { get; set; }

如果你没有一个参考元数据类,可以通过添加属性到局部类添加这个,是这样的:

In case you don't have a reference to the metadata class, you add this by adding the attribute to the partial class, something like this:

[MetadataType(typeof(MyEntityFromTable_MD))]
public partial class MyEntityFromTable
{

}

然后,你需要的元数据类本身。是这样的:

Then you need the metadata class itself. Something like:

public class MyEntityFromTable_MD
{
        [ScaffoldColumn(false)]
        public object Id;
}