asp.net mvc 3 - 2 Models of same Properties, MVC3 -


good day guys!

i've started using mvc3, i've 2 models in application i.e. "page" , "pagehistory" both has same properties. except "pagehistory" has 1 property called "pageid" references "page" model.

my question doing in correct way? or should use inheritance this. if inheritance option, how can handle this, examples me lot.

my model looks follows:

public class page     {         private readonly indiantime _g = new indiantime();          public page()         {             createdon = _g.datetime;             properties = "published";             tags = "page";             relativeurl = string.empty;         }          public string path         {             { return (parentpage != null) ? parentpage.heading + " >> " + heading : heading; }         }          [key]         public int id { get; set; }          [stringlength(200), required, datatype(datatype.text)]         public string title { get; set; }          [stringlength(200), required, datatype(datatype.text)]         public string heading { get; set; }          [maxlength, required, datatype(datatype.html)]         public string content { get; set; }          [display(name = "reference code"), scaffoldcolumn(false)]         public string referencecode { get; set; }          [required]         [remote("checkduplicate", "page", errormessage = "url has taken", additionalfields = "initialurl")]         public string url { get; set; }           [display(name = "created on"), scaffoldcolumn(false)]         public datetime createdon { get; set; }          //parent page object (self reference: parentid = > id)         [display(name = "parent page")]         public int? parentid { get; set; }          [displayformat(nulldisplaytext = "root")]         public virtual page parentpage { get; set; }          public virtual icollection<page> childpages { get; set; }     } 

i don't think inheritance right way, current structure looks ok me.

see if choose make page parent, , pagehistory being inherited page not pagehistory quite put.

your idea of inheritance should come real world implementations, ex. there diff. kinds of pages inheriting super page type, while page history property page rather complex property properties inside it.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -