let's assume, have 2 entities.
class author{ public int id{get;set;} public string name{get;set;} //..... } class article{ public int id{get;set;} public int authorid{get;set;} public string text{get;set;} }
now want add article authorname
property doubling existing author.name simplify resulting linq queries , execution time. i'm sure database used 1 asp.net mvc project. common way implement such column using ef (without database triggers)?
also here can bit more difficult case. let's want have totalwordcountinallarticles
column in author
entity calculated text property of article.
you can add authorname
property article
, manually keep integrity making sure code creates articles
or updates author.name
updates of articles
. same thing totalwordcount
, , time article.text
changes, re-add of counts other articles
.
there few patterns @ make more automatic, such domain event pattern (https://lostechies.com/jimmybogard/2014/05/13/a-better-domain-events-pattern/), isn't plug , play. depends on if these couple of items or if going happen frequently.
if denormalizing data performance, may want @ more of architecture there normalized db , separate process generates denormalized views on data , put document store.
Comments
Post a Comment