PropertyHasChanged() on a Structure

PropertyHasChanged() on a Structure

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


ataylorm posted on Tuesday, December 11, 2007

Good Morning,

Making much progress here, but have a question...  I have a struct called Address, this struct has several properties, Address1, Address2, City, State, and so on.  When I try and have:

public string Address1
{   
   
get {return _Address1;}
   set
   {
      _Address1 =
value;
      PropertyHasChanged(
"Address1");
   }
}

I get the following error:

Error 1 Cannot access protected member 'Csla.Core.BusinessBase.PropertyHasChanged(string)' via a qualifier of type 'ProjectUnicorn.Library.UMUser.UMUserAccount.Address'; the qualifier must be of type 'ProjectUnicorn.Library.UMUser.UMUserAccount.Address' (or derived from it) C:\Code\Project Unicorn\ProjectUnicorn.Library\UMUser.cs 77 25 ProjectUnicorn.Library

Any ideas?

ajj3085 replied on Tuesday, December 11, 2007

I would re-evaluate your design.  You can do lazy loading of properties (if you want Address to be lazy loaded) without using a struct or embedding the struct into a class.

It seems that you're doing "data driven design," which can work with Csla, but you'll be happier and have an easier time with "behavior driven design."  Check out (read, and memorize) chapter 8 to see what I mean.

ataylorm replied on Tuesday, December 11, 2007

The struct actually would be loaded with the class, the idea was to create a cleaner open api and allow for collections of addresses.

ajj3085 replied on Tuesday, December 11, 2007

But the struct can't behave like a business object, and it either probably should, or it should be absorbed into the user class.

Is there a requirement now for a collection of addresses?  I just ask because I try to follow YAGNI design philosophy.

Copyright (c) Marimer LLC