Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't use Entity Models too much, I prefer LINQ - SQL models so this may be incorrect:</p> <p>Why not use a meta-data class which is applied to the Entity? With LINQ - SQL the metadata assigned is taken into consideration for both client-side as well as server-side validation.</p> <p>From what I understand application of a [MetaDataType] attribute is similar to inheritance only it works without implementing a new class (model) for alterations to the basic entity.</p> <p>Also, another option you might want to try is creating a custom attribute - I did this once for a similar purpose. Essentially a flag which indicated the persistence of a member.</p> <p>So i would have an entity defined as follows:</p> <pre><code>public class User { public int Id { get; set; } public string Name { get; set; } public string Email { get; set; } public string Password { get; set; } [DoNotPersist] public string ConfirmPassword {get; set;} } </code></pre> <p>Also, I don't know what you are doing to store data but I had hooked an override into the OnInserting , OnEditing, OnDeleting functions for my DataContext which basically removed any members having my custom attribute. </p> <p>I like this method simple because we use a lot of temporary, rather algorithmic data for each model (building good UI's for Business Intelligence) which is not saved in the database but is used everywhere inside model functions, controllers, etc - so we use dependency injection in all model repositories and controllers and so we have all these extra data points for each table to play with.</p> <p>Hope that helps!</p> <p>PS:- Composition vs Inheritance - it really depends on the target user of the application. If it is for an intranet app where security is less of an issue and the user / browser environment is controlled then just use client side validation, ie: composition.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload