is injecting dao entities bad thing?


so many new .net developers start flitting datasets everywhere nonetheless things office doesn't seem right.



the unbroken impetus wholly emanate entity objects extend dal bottom category have i.e.



public category user : userdal
{
//user specific methods
}
public category userdal
{
//bunch user specific properties
open user load(int id)
{
//some low turn happening calls
}
private user loadfromdataset(dataset ds)
{
//load entity properties dataset
}
}


user extends userdal objects low turn information opening calls controlling ado.net.



from here learn doing means your tied information opening covering removed entity, information opening vigilant dao interface scathing simply barter out dao need be. i.e.



public userdao : iuserdao
{
//data opening functions
}


with generics tact good orm ease some-more common information opening gunk operations i.e.



public userdao<user> : basedao<user>, iuserdao
{
//basedao deals simple gunk some-more tradition information opening methods here
}


so fundamentally that's where i am now at, aside good practices controlling ioc solve specific iuserdao i want. nonetheless while i advantage structure i am also left feeling i skip aged user.load(1) slight calls.



what i wondering such bad thing inject iuserdao user entity have take caring simple gunk operations?



my bargain poco user entity have problems upheld over hoop adding methods save(), load() etc have relavence clarity information send object.



but conspicuous entities wholly have idle hallowed collections meant zero dto sense. also, wfp i trust collect chose properties i wish serializing, during unequivocally slightest i emanate new userdto i need send opposing wire.



so basically, aside emanate problems origination user entity consolidate dataaccess associated methods? also someone explain presumably i am articulate referred an active record settlement something else?



edit:



cristianlibardo noted:




as appetite drawbacks there incomparable coupling peristence code, resitence following/updating associations, testability querying.




there incomparable turn coupling nonetheless i pondering somehting following:



public category user
{
iuserdao userdao;
open user()
{
userdao = ioccontainer.resolve<iuserdao>;
}
open user(iuserdao userdao)
{
this.userdao = userdao;
}
//dal methods
}


so coupling should minimal testability, i don't problem i only inject ridicule dao entity.



thanks brian hasden, unequivocally good resources, nonetheless i speculation i only wanted justification something i apparently going do. interjection giving conspicuous justification.



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?