Hi guys,
I am working on an ASP.NET Core Blazor Server app. I have one to many relationships between Order and OrderDetail entities. I couldn't find a way to insert data into tables from excel upload. Any help would be great.
Thanks in advance.
Here are the entities:
public class Order
{
public int Id { get; set; }
[Required]
public DateTime OrderDateTime { get; set; }
[Required]
[MaxLength(250)]
public string CustomerName { get; set; }
[Required]
[MaxLength(250)]
public string VendorName { get; set; }
public string Status { get; set; }
[MaxLength(50)]
public string DoneBy { get; set; }
public List<OrderDetail> OrderDetails { get; set; }
}
public class OrderDetail
{
public int Id { get; set; }
[Required]
[MaxLength(100)]
public string ProductCode { get; set; }
[Required]
[MaxLength(250)]
public string ProductName { get; set; }
[Required]
public int BuyQuantity { get; set; }
[Required]
public int SellQuantity { get; set; }
public double CostRatio { get; set; }
public double UnitCost { get; set; }
public double TotalBuyPrice { get; set; }
public double TotalSellPrice { get; set; }
[MaxLength(150)]
public string ShippingNumber { get; set; }
public string Status { get; set; }
[MaxLength(150)]
public string TrackingNumber { get; set; }
[MaxLength(400)]
public string Description { get; set; }
public int OrderId { get; set; }
public virtual Order Order { get; set; }
}
Here is the sample excel:
