Guid パラメータを使用して .ToList() を生成するサービスへのアクセスに問題があります。
public IList<Info> GetBusinessLocations(Guid businessId)
{
using (var db = new DealerContext())
{
return GetDealerDetails(
db.Details
.Join(db.BusinessLocations,
x => x.BusinessId,
y => y.BusinessId, (x, y) => x)
.Where(d => d.BusinessId == businessId), db)
.ToList();
}
}
GUID をパラメータとして ActionResult を書き込もうとしましたが、「パラメータ ディクショナリにパラメータ 'businessId' の null エントリが含まれています」というエラーが引き続き発生します。
public ActionResult Create(Guid businessId)
{
ViewBag.Locations = new SelectList(ServiceBus.GetBusinessLocations(businessId), "BusinessId", "LocationName");
return View(IdGenerator());
}
private static Data.Models.Business IdGenerator()
{
var model = new Models.Business
{
BusinessId = Guid.NewGuid()
};
return (model);
}
そして、私の見解では、ドロップダウンリストを呼び出すだけです
@Html.DropDownListFor(m =>m.BusinessId, (IEnumerable<SelectListItem>)ViewBag.Locations,"Select your Businesses Location")
誰かが洞察を提供できれば、私はそれを大いに感謝します。SOで同様のシナリオを見つけるのに苦労しています。