Mark

There is really no need to use TInterfacedObject (which makes your choice of
bases class more flexible)
I'm future profing my TDataSet code with an interface

  TADOEntity = class(TADOQuery, ImwkEntity)
  end

where

  ImwkEntity = interface(IUnknown)
['{181305E0-4E7F-11D4-A02F-00E018A81F7C}']
    function ApplyUpdates: boolean;
    function CancelUpdates: boolean;
    function UpdatesPending: boolean;
    function Mode: TEntityMode;
    function GetMetaName: string;
    function GetMetaServer: TmwkMetaServer;
    procedure SetMetaName(Value: string);
    procedure SetMetaServer(Value: TmwkMetaServer);
    function GetMetaEntity: TmwkMetaEntity;
    function KeyedFieldName: string; // Returns either the PrimaryKey or
KeyField with a matching Param
    function SetEmpty: boolean;      // Trys to set a open dataset to
IsEmpty = true
    function NewEntity(AOwner: TComponent): ImwkEntity;
    function SetSQL(SQL: string): boolean;
    function SetEntitySize(Size: TEntitySize): boolean;
    function DataSet: TDataSet;
    function FieldDataType(index: integer) : TEntityDataType;
    procedure SetMaxRows(Count: integer);
    property MetaServer: TmwkMetaServer read GetMetaServer write
SetMetaServer;
    function KeyLocate(const FieldName: string; Value: Variant): boolean;
    procedure Free;
  end;

2 things of note about this interface

1/    function DataSet: TDataSet; exposes the TDataSet parent (prob 90% of
what you do with a TDataset descendant
        is in the base class

2/   function NewEntity(AOwner: TComponent): ImwkEntity; creates another
dataset of the same class (used for runtime lookup creation)

and in your code you then always make reference to your compnoent via the
Interface ie

var
  EntInt: ImwkEntity;
  Lookup: ImwkEntity;

begin
  if Query.GetInterface(ImwkEntity, EntInt) then
  with EntInt do
  try
    DataSet.FieldByName('Test') := 0 ; //  example of using the TDataset
exposed
...

If you use dynamically created components and a compile time switch then
support for multiple TDataSet descendants is a breeze

HTH
Neven














---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to