c# - Asp.net Core + Entity Framework 7 optimizations? -
have few questions how ef7 + asp.net core works...
1) assume following tables:
users pk=id, etc. roles pk=id, etc. userroles fk=users.id,roles.id
when (pseudo) _context.users.where(x => x.username == "bob").include(...userroles...).theninclude(...roles...)
, debug output, appears ef7 doing optimization , pulls minimal stuff needs populate user poco bob , roles? going hit database every time run statement? i.e. lets first time run it, bob has role of "user". if update table give him role of "admin", going re-pull everything? if delete roll, next time run query, going re-sync everything?
2) appears, in ef7, can't scaffold stored procs, correct? have schema similar this:
tablea tableatob tableb tablebtoc tablec
if catch drift, tablea has m:m relationship tableb (tied tableatob) , tableb has m:m relationship tablec.
what i'm after tablec.name values tablea.name="blah", need join 5 of tables together. if in ef7 table scaffolding, seems i'd have similar question #1 .include() pull 5 tables , populate dbsets of 5 tables when want single column tablec. there better way that?
3) related scenario #2, while i'm interested in subset of tablec described, i'd cache locally don't have hit db on every request. i'd pulling once every 24 hours should sufficient. can't in controller since new controller new'ed every request. there pattern common scenario?
Comments
Post a Comment