I have Brand, Blend, Flavor and Drink classes. Flavor has a Mark and a Blend. Drink consists of a Taste and other fields:
public class Brand{
public int BrandId{ get; set; }
public string Name{ get; set; }
public ICollection<Flavor> Flavors { get; set; }
}
public class Blend{
public int BlendId{ get; set; }
public string Name{ get; set; }
public ICollection<Flavor> Flavors { get; set; }
}
public class Flavor{
public int FlavorId{ get; set; }
public int BrandId{ get; set; }
public Brand Brand{ get; set; }
public int BlendId{ get; set; }
public Blend Blend{ get; set; }
}
public class Drink{
public int DrinkId{ get; set; }
public int FlavorId{ get; set; }
public Flavor Flavor{ get; set; }
}
I need that when creating a new drink (Views / Drink / Create.cshtml) the user selects a flavor as a string (Coca-Cola Vanilla) and not for its Id. In the case of creating a new flavor, for example, you can send Text and Value of each Brand to that of via:
ViewData["BrandId"] = new SelectList(_context.Brands, "BrandId", "Name");
but in this case it is required to access the Name field of two instances How can I do it?