views:

245

answers:

2

I inherited a project with a Windows mobile part. To make a long story short, my problem is this:

[DBPropertyUpdate("CustomerId")]
[DBPropertyRetrieve("CustomerId")]
public CustomerBase<T> Customer
{
    get { return _customer; }
    set { _customer = SetProperty(_customer, value); }
}

throws an exception.

In a watch window I have the following:

> NAME         VALUE                           TYPE

_customer   {Pss.Common.Mia.Customer} Pss.Common.Mia.CustomerBase<System.Guid> {Pss.Common.Mia.Customer}
(Pss.Common.Mia.CustomerBase<System.Guid>)_customer Cannot convert type 'Pss.Common.Mia.CustomerBase<T>' to 'Pss.Common.Mia.CustomerBase<System.Guid>'

I am not familiar with this code, but was hoping there would be some easy way to convert 'Pss.Common.Mia.CustomerBase<T>' to 'Pss.Common.Mia.CustomerBase<System.Guid>' The seconcd Watch entry was my attemp, which as you can see fails.

+1  A: 

The variable _customer typed as CustomerBase<Guid> cannot possibly be cast to CustomerBase<T> since T is not known. You must also type _customer as CustomerBase<T> for this to work.

Peter Lillevold
A: 

Got it working by passing CustomerBase<Guid> as type to the function which builds the customer object

callisto