Asp.net mvc 几种模型中的附着特性
我正在使用ASP.NETMVC+LinqToSQLAsp.net mvc 几种模型中的附着特性,asp.net-mvc,linq-to-sql,Asp.net Mvc,Linq To Sql,我正在使用ASP.NETMVC+LinqToSQL 我的应用程序中有附件模型。我需要几个型号的附件。我不想为不同的父类创建不同的附件模型。有简单的方法吗?您的意思是希望在模型中的更多位置使用附件吗?例如,员工对象和客户对象?你是说: public class Attachment { /* Various properties... */ } public class Attachments : List<Attachment> { public void DoSomething(
我的应用程序中有附件模型。我需要几个型号的附件。我不想为不同的父类创建不同的附件模型。有简单的方法吗?您的意思是希望在模型中的更多位置使用附件吗?例如,员工对象和客户对象?你是说:
public class Attachment { /* Various properties... */ }
public class Attachments : List<Attachment>
{
public void DoSomething()
{
foreach (Attachment attachment in this)
DoSomethingToAttachment(attachment);
}
}
public interface IAttachmentHandler
{
void HandleAttachments();
}
public class Employee : IAttachmentHandler
{
private Attachments _attachments;
public void HandleAttachments()
{
_attachments.DoSomething();
}
}
public class Customer : IAttachmentHandler
{
private Attachments _attachments;
public void HandleAttachments()
{
_attachments.DoSomething();
}
}
我想你的意思是轨道作为一种附件?您可能希望编辑您的问题,以具体反映文件附件,如果这是您的意图?