New Posts New Posts RSS Feed: Generic Base Class for entities
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Generic Base Class for entities

 Post Reply Post Reply
Author
tersiusk View Drop Down
Newbie
Newbie
Avatar

Joined: 03-Nov-2010
Posts: 20
Post Options Post Options   Quote tersiusk Quote  Post ReplyReply Direct Link To This Post Topic: Generic Base Class for entities
    Posted: 11-Nov-2010 at 12:58am
Hi sbelini

I'm getting the error on the SaveChanges()

Here is a sample solution. uploads/988/DevforceTemplate.rar


Edited by tersiusk - 11-Nov-2010 at 1:03am
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 10-Nov-2010 at 4:23pm
Hi tersiusk,
 
Upon what operation are you getting the exception?
Are you using an injected base type? (you can do that in your model properties)
Can you upload a small sample (against northwindIB) reproducing the issue?
 
Back to Top
tersiusk View Drop Down
Newbie
Newbie
Avatar

Joined: 03-Nov-2010
Posts: 20
Post Options Post Options   Quote tersiusk Quote  Post ReplyReply Direct Link To This Post Posted: 08-Nov-2010 at 8:48am
I want a generic class to do some type safe methods etc. For instance I want all my entities to have a GetAll method which need to return ObservableCollection<T>. 
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 08-Nov-2010 at 8:26am
Why exactly do you need a Generic class?

When you have a base class EntityBase, User will inherit from EntityBase. You do not need to make it Generic
Back to Top
tersiusk View Drop Down
Newbie
Newbie
Avatar

Joined: 03-Nov-2010
Posts: 20
Post Options Post Options   Quote tersiusk Quote  Post ReplyReply Direct Link To This Post Posted: 08-Nov-2010 at 7:20am
Hi

I have created a generic base class for my entities but I'm running into some issues with the serialization. I have defined the generic class as below. 
public abstract class EntityBase<T> : EntityBase
{      
}
I'm getting Error:
while getting known types for Type 'NetstarSecurity.DevForce.Model.EntityBase`1[T]'. The type must not be an open or partial generic class.
Now obviously my basetype is a open generic class...
I have tried adding the [KnownType(typeof(EntityBase<User>))] attribute but it still gives the same error. 

Please help. :)
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down