简体   繁体   English

生成密封类

[英]Generate sealed classes

Using linq to sql I would like to generate some sealed classes in a data context. 使用linq to sql我想在数据上下文中生成一些密封的类。 Apparently that can't be done. 显然,这无法完成。

When I try to extend a generated class, let's say ApplicationUser by a partial part like this 当我尝试扩展生成的类时,让ApplicationUser像这样的一部分

sealed public partial class ApplicationUser
{ }

I get compilation errors (summarized) 我收到编译错误(摘要)

'SendPropertyChanging()' is a new virtual member in sealed class 'ApplicationUser' “ SendPropertyChanging()”是密封类“ ApplicationUser”中的新虚拟成员

and

'SendPropertyChanged(string)' is a new virtual member in sealed class 'ApplicationUser' 'SendPropertyChanged(string)'是密封类'ApplicationUser'中的新虚拟成员

obviously because these methods are generated as protected virtual . 显然因为这些方法是作为protected virtual生成的。

Is there a way to let linq to sql generate selected (not all) classes as sealed? 有没有办法让linq to sql生成选定的(不是全部)类作为密封对象?

You can generate a sealed class by editing the properties in the designer: 您可以通过在设计器中编辑属性来生成密封类:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM