0
iamnish created
while creating new record error is coming .Reading record is working fine.mentioned below Error,Model entity ,Input entity
error : A first chance exception of type 'AutoMapper.AutoMapperMappingException' occurred in AutoMapper.dll
salemast class
public virtual int TenantId { get; set; }
[Table("Sale_Mast")]
public class Salemast : FullAuditedEntity, IMustHaveTenant
{
public virtual int TenantId { get; set; }
[Required]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public virtual System.DateTime Invdt { get; set; }
[Required]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public virtual System.DateTime Invduedt { get; set; }
[Required]
public virtual string Currency { get; set; }
[Required]
public virtual decimal Currate { get; set; }
[Required]
public virtual string Custid { get; set; }
[Required]
public virtual bool Export { get; set; }
[Required]
public virtual string Comments { get; set; }
[Required]
[StringLength(50)]
public virtual string Invno { get; set; }
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public virtual int Sslno { get; set; }
public virtual string Branchid { get; set; }
public virtual ICollection<Saledetails> Saledetails { get; set; }
}
[AutoMapFrom(typeof(Salemast))] public class CreateSaleInput : IInputDto {
[Required]
public System.DateTime Invdt { get; set; }
[Required]
public System.DateTime Invduedt { get; set; }
[Required]
public string Currency { get; set; }
[Required]
public decimal Currate { get; set; }
[Required]
public string Custid { get; set; }
public bool Export { get; set; }
public string Comments { get; set; }
[Required]
[StringLength(50)]
public string Invno { get; set; }
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Sslno { get; set; }
public string Branchid { get; set; }
}
2 Answer(s)
-
0
You used AutoMapFrom. This maps Salemast to CreateSaleInput and I it's wrong. You can use AutoMap:
[AutoMap(typeof(Salemast))]
see document: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Data-Transfer-Objects#DocAutoMapping">http://www.aspnetboilerplate.com/Pages/ ... utoMapping</a>
-
0
yes , I have corrected it thanks :D