DALocalDataAdapter Issue

Hi,

I’ve codefirst DA server 's login class declare as

type
  { TLoginService }
  [ROService('LoginService', '{99DA7AB4-FD41-40D5-85AD-7B5652ECEF8C}')]
  [RONamespace('TemplServer')]
  TLoginService = class(TSimpleLoginService)

In one the Function I need use the DALocalDataAdapter

function TLoginService.LoginChk: Boolean;
var
  lda : TDALocalDataAdapter;
begin

  lda := TDALocalDataAdapter.Create(Self);
  lda.ServiceInstance := Self; << error
end;

I got Error
[dcc32 Error] LoginService_Impl.pas(159): E2010 Incompatible types: 'IDataAbstractLocalServiceAccess' and 'TLoginService'

Any Advise?

Hi,

Only TDataAbstractService descendant can be used as service instance for TDALocalDataAdapter.

it was a security hole when Login service could be used as usual DataService.

workarounds:

  • specify usual DataService as the service instance
  • you can use Schema.NewDataset like
var
  lDataset: IDADataset;
  lWhere: TDASQLWhereBuilder;
begin
  try
    lwhere := Connection.GetWhereBuilder;
    try
    lWhere.Expression := lWhere.NewBinaryExpressionList(
      [lWhere.NewBinaryExpression('','Login',dboEqual,aUserID,datString),
      lWhere.NewBinaryExpression('','Password',dboEqual,aPassword,datString)],
      dboAnd);
    lDataset := Schema.NewDataset(Connection, 'Users',[],lWhere.Xml);
    finally
      lWhere.Free;
    end;
    lDataset.Open;

I try to find the backup source and try to add localdatapter to this source ( delphi 10…3.3 and DA 10.0.1463) . After that convert to code first server, it can compile.

Is it newly changes on this?

However I will use your way to handle it , the above for your information.

Joe

Hi,

it was changed in .1491 (~1.5 years ago)
check Data Abstract for Delphi vNext: New features or Breaking Changes for more details.