对象引用不....在_mscustomerRepository.Insert(customer)时;

时间:2013-07-17 07:06:21

标签: asp.net asp.net-mvc-3 nopcommerce

我正在研究Nopcommerce 2.40。我在项目中创建了新表,它的类和映射

班级代码

namespace Nop.Core.Domain.Customers
{
   public partial class MSCustomer:BaseEntity
    {


       public virtual string Name { get; set; }

        public virtual string Email { get; set; }

        public virtual string Address { get; set; }

       public virtual string PhoneNumber { get; set; }

       public virtual string ComapnyName { get; set; }


        public virtual DateTime CreatedOnUtc { get; set; }


    }
}

以下是我的映射

 public partial class MSCustomerMap : EntityTypeConfiguration<MSCustomer>
    {
        public MSCustomerMap()
        {
            this.ToTable("MSCustomer");
            this.HasKey(c => c.Id);
            this.Property(u => u.Name).HasMaxLength(1000);
            this.Property(u => u.Address).HasMaxLength(1000);
            this.Property(u => u.Email).HasMaxLength(100);
            this.Property(c => c.PhoneNumber).HasMaxLength(100);
            this.Property(c => c.CompanyName).HasMaxLength(100);

        }
    }



public virtual void CreateCustomer(MSCustomer customer)
        {
            if (customer == null)
                throw new ArgumentNullException("cutomer");

            _mscustomerRepository.Insert(customer);

            //event notification
            _eventPublisher.EntityUpdated(customer);

        }

我在数据库中创建了“MScustomer”表,但在插入时抛出了“对象引用未设置为对象实例”的抛出错误。

在Controller中我将值赋给属性并将customer类传递给insert方法。 有没有解决方案。

它在_mscustomerRepository.Insert(customer);

中抛出异常

提前致谢

0 个答案:

没有答案