mrbar2000
unread,Feb 9, 2012, 9:57:31 AM2/9/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to dorm, The Delphi ORM
Hi Daniele,
While refactoring the session, I touch on Load, FindOne, FindAll, List
and Fill(s) methods.
I think that all this routines are very similar then I have a idea to
let this session simpler.
I have mapped all methods that we have on dorm to read object and
collection of objects. this is the results
TSession.Load(ATypeInfo: PTypeInfo; const AValue: TValue):
TObject;
TSession.Load<T>(const Value: TValue): T; ==> CALL 1
TSession.FillList<T>(ACollection: TObject; AItemClassInfo:
PTypeInfo; Criteria: TdormCriteria; FillOptions: TdormFillOptions;
FreeCriteria: Boolean);
TSession.FillList<T>(ACollection: TObject; AdormSearchCriteria:
IdormSearchCriteria; FillOptions: TdormFillOptions);
TSession.FillList<T>(ACollection: TObject; Criteria:
TdormCriteria; FillOptions: TdormFillOptions; FreeCriteria: Boolean);
TSession.FindOne(AItemClassInfo: PTypeInfo; Criteria:
TdormCriteria; FillOptions: TdormFillOptions; FreeCriteria: Boolean):
TObject;
TSession.FindOne<T>(Criteria: TdormCriteria; FillOptions:
TdormFillOptions; FreeCriteria: Boolean): T;
TSession.List<T>(AdormSearchCriteria: IdormSearchCriteria): {$IF
CompilerVersion > 22}TObjectList<T>{$ELSE}TdormObjectList<T>{$IFEND};
TSession.List<T>(AItemClassInfo: PTypeInfo; Criteria:
TdormCriteria; FillOptions: TdormFillOptions; FreeCriteria: Boolean):
{$IF CompilerVersion > 22}TObjectList<T>{$ELSE}
TdormObjectList<T>{$IFEND};
TSession.List<T>(Criteria: TdormCriteria; FreeCriteria: Boolean =
true): {$IF CompilerVersion > 22}TObjectList<T>{$ELSE}
TdormObjectList<T>{$IFEND};
TSession.ListAll<T>(FillOptions: TdormFillOptions = []): {$IF
CompilerVersion > 22}TObjectList<T>{$ELSE}TdormObjectList<T>{$IFEND};
What u think about to use criteria for all! Relax i will explain
better.
On session we could have just
TSession.Load<T>(ICriteria<T>): T
TSession.Load<T>(OidValue): T => internally this call
TSession.Load<T>(ICriteria<T>): T
TSession.NewCriteria<T>: TCriteria<T> or ICriteria<T>
Look that just with this 3 methods we could load anything!
On TSession.NewCriteria we could create a TCriteria passing the
session (self).
ICriteria<T> could have 2 methods GetList<T> and GetOne<T>
so when programmer call one of this 2 methods we could call Result :=
Session.Load<T>(Self).
IdormSearchCriteria (that I would rename to ICustomCriteria) could
inherited from ICriteria, then on Persister.Load we could verify if
that criteria instance implements ICustomCriteria call the rightly
methods.
Any query will be simpler this way!
The only problem here is about circular reference, but this could be
resolved using interfaces OR puting TSession and TCriteria into same
unit.
What u think?