Search Results

Search found 4 results on 1 pages for 'juvaly'.

Page 1/1 | 1 

  • Inheritance with POCO entities in Entity Framework 4

    - by Juvaly
    Hi All, I have a Consumer class and a BillableConsumer : Consumer class. When trying to do any operation on my "Consumers" set, I get the error message "Object mapping could not be found for Type with identity Models.BillableConsumer. From the CSDL: <EntityType Name="BillableConsumer" BaseType="Models.Consumer"> <Property Type="String" Name="CardExpiratoin" Nullable="false" /> <Property Type="String" Name="CardNumber" Nullable="false" /> <Property Type="String" Name="City" Nullable="false" /> <Property Type="String" Name="Country" Nullable="false" /> <Property Type="String" Name="CVV" Nullable="false" /> <Property Type="String" Name="NameOnCard" Nullable="false" /> <Property Type="String" Name="PostalCode" Nullable="false" /> <Property Type="String" Name="State" /> <Property Type="String" Name="StreetAddress" Nullable="false" /> </EntityType> From the C-S: <EntitySetMapping Name="Consumers"> <EntityTypeMapping TypeName="IsTypeOf(Models.Consumer)"> <MappingFragment StoreEntitySet="consumer"> <ScalarProperty Name="LoginID" ColumnName="LoginID" /> <ScalarProperty Name="FirstName" ColumnName="FirstName" /> <ScalarProperty Name="LastName" ColumnName="LastName" /> </MappingFragment> </EntityTypeMapping> <EntityTypeMapping TypeName="IsTypeOf(Models.BillableConsumer)"> <MappingFragment StoreEntitySet="billinginformation"> <ScalarProperty Name="CardExpiratoin" ColumnName="CardExpiratoin" /> <ScalarProperty Name="CardNumber" ColumnName="CardNumber" /> <ScalarProperty Name="City" ColumnName="City" /> <ScalarProperty Name="Country" ColumnName="Country" /> <ScalarProperty Name="CVV" ColumnName="CVV" /> <ScalarProperty Name="LoginID" ColumnName="LoginID" /> <ScalarProperty Name="NameOnCard" ColumnName="NameOnCard" /> <ScalarProperty Name="PostalCode" ColumnName="PostalCode" /> <ScalarProperty Name="State" ColumnName="State" /> <ScalarProperty Name="StreetAddress" ColumnName="StreetAddress" /> </MappingFragment> </EntityTypeMapping> </EntitySetMapping> Is this because I did not specifically add the BillableConsumer entity to the object set? How do I do that in a POCO scenario? Thanks! UPDATE: I decided to test whether or not POCOs generated with the T4 template would solve the problem and they did. The most annoying part is that when I restored my original classes from SVN to try and figure out how they are different - they worked as well!! Not adding this as an answer because someone else might have an actual explanation...

    Read the article

  • Is there a way to update a ViewModel in MVC2?

    - by Juvaly
    This code works: [HttpPost] public ActionResult Edit(int id, FormCollection fc) { Movie movie = ( from m in _ctx.Movie.Include("MovieActors") where m.MovieID == id select m ).First(); MovieActorViewModel movieActor = new MovieActorViewModel(movie); if (TryUpdateModel(movieActor)) { _ctx.ApplyPropertyChanges(movieActor.Movie.EntityKey.EntitySetName, movieActor.Movie); _ctx.SaveChanges(); } return View(movieActor); } However, I am not sure how to test this, and in general would much rather have the method take a typed model like: [HttpPost] public ActionResult Edit(MovieActorViewModel movieActor) Is this possible? What changes to my MovieActorViewModel class do I need to make in order to enable this? That class looks like this: public class MovieActorViewModel { public Movie Movie { get; set; } public Actor Actor { get; set; } public PublisherDealViewModel(Movie movie) { this.Movie = movie; this.Actor = ( from a in this.Movie.Actors where a.ActorID == 1 select a ).First(); } } The view is typed (inherits ViewPage) simple: <% using (Html.BeginForm()) {%> Movie Title: <%= Html.TextBoxFor(model=>model.Movie.Title) %><br/> Actor Name: <%= Html.TextBoxFor(model=>model.Actor.Name) %> <% } %>

    Read the article

  • DisplayFor ignores metadata

    - by Juvaly
    For my Contact class, the property EmailAddress is marked with the [DataType(DataType.EmailAddress)] attribute. In my view, using Html.Display("EmailAddress") and Html.DisplayFor(c => c.EmailAddress) yields different results. The former outputs a mailto: link, which is the expected behavior, while the latter simply outputs the email address as plain text. My question is why the different behavior, I expected these two methods to have the same output.

    Read the article

  • How to retrieve base class only (entity framework)?

    - by Juvaly
    Hi All, I've been scratching my head here for a while now... I have a Consumer class and a BillableConsumer class that inherits Consumer. They are both a part of the Consumers set. The problem is that this following query: Consumer consumer = (from c in _ctx.Consumers where c.ID = id select c).First(); returns a BillableConsumer instance! Just the same as this query: BillableConsumer bconsumer = (from c in _ctx.Consumers.OfType<BillableConsumer>() where c.ID = id select c).First(); How can I return an instance of just the base class? (these are separate tables in the data store).

    Read the article

1