Strange Inheritence Issues with Property Registration

Strange Inheritence Issues with Property Registration

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


mcalhoun posted on Friday, June 11, 2010

I am having a strange issue with property registration when using inheritence. Below is how my classes are setup. I'm using CSLA 4 beta for Silverlight.

I get a message that says "Cannot resolve symbol 'Test'" and the c.Test lamda turns red in Visual Studio 2010. The lamda intellisense doesn't seem to see the Test property. If I change the base class to BusinessBase<Customer> then it works properly. What am I missing here?

Thanks,
Matt

public abstract class MyAppBusinessBase<T> : BusinessBase<MyAppBusinessBase<T>>
{
...
}

public class Customer : MyAppBusinessBase<T>
{
   public static PropertyInfo<string> TestProperty = RegisterProperty<string>(c => c.Test);
   public string Test
   {
     get { return GetProperty(TestProperty); }
     set { SetProperty(TestProperty, value); }
   }
}

RockfordLhotka replied on Friday, June 11, 2010

You abstract base class is introducing a whole other level of indirection that you don't want. It should be

public abstract class MyAppBusinessBase<T> : BusinessBase<T> where T : MyAppBusinessBase<T>

mcalhoun replied on Friday, June 11, 2010

Thanks Rocky! That was my initial thought, but I was missing the where constraint on the base class...duh!

Matt

Copyright (c) Marimer LLC