DataPortal_XYZ, access enterprise services component

DataPortal_XYZ, access enterprise services component

Old forum URL: forums.lhotka.net/forums/t/2416.aspx


Zygimantas posted on Friday, February 23, 2007

Hello,

Is it possible (and how) to pass Criteria object to Enterprise Services component from DataPortal_XYZ methods and update the caller object? For example:

public class Identity
{
    private Boolen isAuthenticated;
    private String failureReason;

    public Boolen IsAuthenticated
    {
        get { return this.isAuthenticated; }
    }

    public Boolen FailureReason
    {
        get { return this.failureReason; }
    }

    private class Criteria
    {
        private String username;
        private String password;

        public String Username
        {
            get { return this.username; }
        }

        public String Password
        {
            get { return this.password; }
        }
    }

    private void DataPortal_Fetch(Criteria criteria)
    {
        // 1 : typical simplified authentication - no problems
        //
        // if (criteria.Username == "Administrator" && criteria.Password == "password") { this.isAuthenticated = true; this.failureReason = ""; }

        // 2: authentication must be done in ES component because object pooling is required
        // CustomDataAccessComponent is Enterprise Service component
        //
        // using (CustomDataAccessComponent component = new CustomDataAccessComponent())
        // {
        //     ???
        // }
    }
}

Thank you for your help!

Zygimantas replied on Friday, February 23, 2007

I have found Rockford's solution to simmilar problem in this topic http://forums.lhotka.net/forums/permalink/11272/11565/ShowThread.aspx#11565 but could you please provide more details how to implement DataServiceFactory?

 

[Serializable]
public class Customer : BusinessBase<Customer>
{
  // ...
  protected override void DataPortal_Fetch(Criteria criteria)
  {
    using (DataService svc = DataServiceFactory.GetService<Customer>())
    {
      DataObjects.CustomerQuery query = new DataObjects.CustomerQuery();
      Csla.Data.DataMapper.Map(criteria, query);
      DataObjects.CustomerData result = svc.GetObject(query);
      _id = result.Id;
      _name = result.Name;
      // etc...
    }
  }
  // ...
}

Copyright (c) Marimer LLC