Problem z modelem domenowym

0

Cześć. Mam taki problem oto moj model domenowy OrderItem:

public class OrderItem
    {

        protected OrderItem()
        {

        }

        public OrderItem(Guid productId, decimal price, string userId)
        {
            Id = Guid.NewGuid();
            ProductId = productId;
            Price = price;
            CustomerId = HttpContext.Current.User.Identity.GetUserId();
            Quantity = 1;
            UserId = userId;
        }

        public Guid Id { get; protected set; }
        public Guid OrderId { get; protected set; }
        public Guid ProductId { get; protected set; }
        public int Quantity { get; protected set; }
        public decimal Price { get; protected set; }
        public string UserId { get; protected set; }
        public OrderStatus OrderStatus { get; protected set; }
        public string CustomerId { get; protected set; }

        public virtual Product Product { get; protected set; }
        public virtual Order Order { get; protected set; }



        public string ProductName()
        {
            return Product.Name;
        }



        public void inproveQuantity( Product product)
        {
            this.Quantity++;
            if (this.Quantity > this.Quantity)
            {
                this.Quantity = product.Quantity;
            }
        }
    }
    public enum OrderStatus
    {
        Nowe, Zrealizowane
    }

Nie wiem czemu ale jak chcę zwrócić Nazwę Produktu jest null. Dlaczego kurcze ? W innym modelach domenowych mi to działa

1

Produkt (obiekt) jest nullem czy nazwa (string)? Jeśli to pierwsze to zapewne nie ładujesz produktu przy wczytywaniu z bazy.

1 użytkowników online, w tym zalogowanych: 0, gości: 1