How to set field with another one

Cenk 956 Reputation points
2022-08-12T06:39:43.837+00:00

Hello,

I have this OrderDetail class. I want to set the Currency field to ExtendedCurrency. Can I set it in the LINQ query below? Or is it possible to set it in the class?

Thank you.

public async Task<IEnumerable<Order?>> GetAllOrders()  
{  
   return await _db.Orders.Include(d => d.OrderDetails).ThenInclude(v => v.Vendor).ToListAsync();  
}  

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 string Currency { get; set; }  
        public int OrderId { get; set; }  
        public int VendorId { get; set; }  
        public Order Order { get; set; }  
        public Vendor Vendor { get; set; }  
        [NotMapped] public string? ExtendedCurrency { get; set; }  
  
    }  
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
696 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,277 questions
{count} votes