Quantcast
Viewing all articles
Browse latest Browse all 764

Factory Command object failing in e-book sample

Hi,

I'm getting back into CLSA after a long pause (last used 2.0). I was working through the samples from the e-book and noticed that the PersonsUpdater file was missing in the FactoryImplementation from the DataAccess book.

I tried to recreate it, but the tests are still failing.

Here is my implementation.

namespace Library
{
  [Csla.Server.ObjectFactory("PersonDal")]
  [Serializable]
  public class PersonsUpdater : CommandBase<PersonsUpdater>
  {
    public static readonly PropertyInfo<PersonEdit> Person1Property = RegisterProperty<PersonEdit>(c => c.Person1);
    public PersonEdit Person1
    {
      get { return ReadProperty(Person1Property); }
      private set { LoadProperty(Person1Property, value); }
    }

    public static readonly PropertyInfo<PersonEdit> Person2Property = RegisterProperty<PersonEdit>(c => c.Person2);
    public PersonEdit Person2
    {
      get { return ReadProperty(Person2Property); }
      private set { LoadProperty(Person2Property, value); }
    }

    public static void Update(PersonEdit person1, PersonEdit person2, EventHandler<DataPortalResult<PersonsUpdater>> callback)
    {
      var cmd = new PersonsUpdater { Person1 = person1, Person2 = person2 };
      DataPortal.BeginExecute<PersonsUpdater>(cmd, callback);
    }

#if !SILVERLIGHT
    public static PersonsUpdater Update(PersonEdit person1, PersonEdit person2)
    {
      var cmd = new PersonsUpdater { Person1 = person1, Person2 = person2 };
      return DataPortal.Execute<PersonsUpdater>(cmd);
    }
#endif
  }
}

The test is failing with the following exception

Test method Test.Library.Net.PersonsUpdaterTest.PersonsUpdaterUpdateTest threw exception:
Csla.DataPortalException: DataPortal.Update failed (System.ArgumentException: Target object must implement IManageProperties
   at Csla.Server.ObjectFactory.LoadProperty[P](Object obj, PropertyInfo`1 propertyInfo, P newValue)
   at DataAccess.SqlCe.PersonDal.Execute(PersonsUpdater obj) in C:\Programme\Marimer LLC\CSLA .NET\Books\Using CSLA\Samples\03-DataAccess-110311\03-DataAccess-110311\FactoryImplementation\DataAccess.SqlCe\PersonDal.cs:line 186
   at lambda_method(Closure , Object , Object[] )
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Boolean hasParameters, Object[] parameters)) ---> Csla.Reflection.CallMethodException: Execute method call failed ---> System.ArgumentException: Target object must implement IManageProperties

What am I missing?

Thanks

Ben

 


Viewing all articles
Browse latest Browse all 764

Trending Articles