I have run into a situation where I can't see any good solutions, and I'm
hoping someone has run into a similar situation.
I have a generic IRepository<T> interface which is used for loading data
from a store. I have the generic parameter as I want to allow typed queries
(the queries will end up hitting a ANDS service). I want to use classes
implementing interface this in custom controls and ModelViews in a
Silverlight 4 application.
The problem is that you can't have a generic interface in a class without
having a generic type on the class.
public class ControlBase {
protected IRepository<T> _repository;
}
will not compile. As this is a base class, I can't specify the T unless
I use a inherited base DataClass. I would like to use POCOs if possible.
In the fantasy world in my head, I would simply make the base class generic,
and Bob's your uncle. However, I want these classes to be easily consumed in
XAML, which doesn't have a good way to instantiate a generic type.
What I ultimately want is for the user to be able to create the control/form
(bound to ModelView) without a generic type, but that the data access occurs
in a typed way. For example:
public class CoolControl : ControlBase {
public CoolControl() {
_repository = IoC.Resolve<IRepository<SomeConcreteDataType>>();
}
public LoadData () {
// do some typed IQueryable stuff on repository
}
}
With this, the user can specify the control/ViewModel in XAML, and the
control/ViewModel author gets the benefit of typing.
Is there any good way to do this or I am stuck?
Thanks,
Erick
--
You received this message because you are subscribed to the Google Groups
"Seattle area Alt.Net" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/altnetseattle?hl=en.