Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Issue with a EF Model having a property that is also a Model

$
0
0

Hello,

I have an EF Model, lets call it Model 1, in C# that has 4 columns, CreatedBy, CreatedByDate,ModifiedBy,ModifiedByDate,

this model has a property that is a different model that has the same 4 properties, lets call that Model 2

When I reference the Model 2 in an MVC View, instead of showing the values for Model 2 for these 4 columns, it shows the values of those columns in Model 1.

Has anyone else encountered this same issue? Does anyone know of a solution?

Here is an example of what I am trying to do in C#

@model Model1

@if (Model1.Model2.Where(x => x.ProjectID == Model.ID).Count() > 0)
{
Model1.Model2 = Model1.Model2.Where(x => x.ProjectID == Model.ID).ToList();

foreach(var action in Model1.Model2)

{

<td>
@Html.Editor("CreatedBy", action.CreatedBy)
</td>
<td>
@Html.Editor("CreatedDate", action.CreatedDate)
</td>
<td>
@Html.Editor("ModifiedBy", action.ModifiedBy)
</td>
<td>
@Html.Editor("ModifiedDate", action.ModifiedDate)
</td>

}

Thank you,

George


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>