Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 几种模型中的附着特性_Asp.net Mvc_Linq To Sql - Fatal编程技术网

Asp.net mvc 几种模型中的附着特性

Asp.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(

我正在使用ASP.NETMVC+LinqToSQL


我的应用程序中有附件模型。我需要几个型号的附件。我不想为不同的父类创建不同的附件模型。有简单的方法吗?

您的意思是希望在模型中的更多位置使用附件吗?例如,员工对象和客户对象?你是说:

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();
    }
}

我想你的意思是轨道作为一种附件?您可能希望编辑您的问题,以具体反映文件附件,如果这是您的意图?