I am using EF6 and doing some LINQ joins and then passing new structures to the view. Problem is it then throws Microsoft.CSharp.RuntimeBinder.RuntimeBinderException
since these new joined structures are internal.
C#
var carMains = this.DatabaseManager.carClaims.Join(this.DatabaseManager.carConvictions, l => l.request_id, r => r.request_id, (l, r) => new { l.claim_amount, r.conviction_driver }).Take(10);
return View("CarJoin", carMains.ToList());
view
@model dynamic
@foreach (var m in Model)
{
<br>
<div>@(m.claim_amount ?? "")</div>
<br>
<div>@(m.conviction_driver ?? "")</div>
<br>
}
The way I see it solution is to create object for each join and have strongly typed views which would be extremely time consuming as we are talking multiple db models with 200+ entities.
I am sure someone has already been in this situation by now and probably found some less time consuming solution. How can I pass structures to views without having to explicitly define them?