c# - Entity Framework Include without Relations -
i working on huge project using entity framework. because made entities time-dependent not possible use relations between entities anymore (i manage relations myself). problem came not longer able query data before. have entity called student
. entity contains collection of books
(list) belong student. each book contains author property comes database well. load students theirs book , corresponding authors either have write hundreds of custom queries (f.e. linq) or lazy load them results in big performance impact. great if use inlude of entity framework without relations. know how achieve this? thank you.
if entity framework not managing relations between tables, has no way of using .include()
create joins in sql call. best option add related entities parent normal, use [notmapped]
attribute. can use custom sql call perform lookups , populate properties when need them. confused, however, statement because entities "time-dependent" can't use relationships, foreign keys in database... perhaps there's else can optimize entities. if managing own relationships between items, offloading lot of responsibility db app, seems lot of work already.
update
implementing audit trail standard process in entity framework, , easier managing relationships. audit trail involves having event handler context_savingchanges()
method, , working new data , old data through objectstatemanager
. adding logic within loop invalidate or reject additions/updates don't fall within specific time frame.
a example of audit manager on codeproject, author demonstrates method not store audit information, roll back.
Comments
Post a Comment