New Posts New Posts RSS Feed: Object must implement IConvertible Error  when saving inherited entities
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Object must implement IConvertible Error when saving inherited entities

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

Joined: 30-Sep-2010
Location: Nigeria
Posts: 2
Post Options Post Options   Quote uwascan Quote  Post ReplyReply Direct Link To This Post Topic: Object must implement IConvertible Error when saving inherited entities
    Posted: 30-Sep-2010 at 1:29am
I have used Inheritance in my edmx model. I get the above error when I call Save Changes. I also discovered that some of the entities make it to the db despite the error. Please how do one work with inherited entities. Sample code below.

        Administrator admin = new Administrator()
        {
            LastName = "The Name -" + DateTime.Now.Ticks.ToString(),
            FirstName = "Fast Name -" + DateTime.Now.Ticks.ToString(),
            AdminDate = DateTime.Now.Date,
        };

        Instructor teacher = new Instructor()
        {
            LastName = "De Name -" + DateTime.Now.Ticks.ToString(),
            FirstName = "La Name -" + DateTime.Now.Ticks.ToString(),
            HireDate = DateTime.Now.Date,
        };

        Student stud = new Student()
        {
            LastName = "sir Name -" + DateTime.Now.Ticks.ToString(),
            FirstName = "for Name -" + DateTime.Now.Ticks.ToString(),
            EnrolmentDate = DateTime.Now.Date,
            Degree = "Framework 101",
            Credits = 4.6
        };

        BusinessStudent bizStud = new BusinessStudent()
        {
            LastName = "As Name -" + DateTime.Now.Ticks.ToString(),
            FirstName = "Vern Name -" + DateTime.Now.Ticks.ToString(),
            EnrolmentDate = DateTime.Now.Date,
            Degree = "Entity 101",
            Descipline = "Admin",
            BusinessCredit = 5.3,
            Credits = 4.6
        };

        bizStud.EntityAspect.AddToManager();
        teacher.EntityAspect.AddToManager();
        admin.EntityAspect.AddToManager();
        stud.EntityAspect.AddToManager();

        db.SaveChanges(); //This line throws Object must implement IConvertible exception
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: 05-Oct-2010 at 11:06am

uwascan,

 
Which entities get into the db and which do not?
 
Any particular difference between the classes whose entities get into the db and the classes whose entities do not?
 
Also, can you provide a test case against northwindIB, so I can verify the behavior here?
Back to Top
uwascan View Drop Down
Newbie
Newbie
Avatar

Joined: 30-Sep-2010
Location: Nigeria
Posts: 2
Post Options Post Options   Quote uwascan Quote  Post ReplyReply Direct Link To This Post Posted: 08-Oct-2010 at 12:39am
Hi, thanks for your reply. All other entities except BusinessStudent get saved to the db.
I think DevForce does not currently support Multiple Inheritance i.e
Person ------> base object
Admin ----> inherits from Person
Instructor ----> inherits from Person
Student ----> inherits from Person
BusinessStudent ----> inherits from student

BusinessStudent  cannot be saved in this case. Entity Framewrok can handle this scenario with out problems.

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: 08-Oct-2010 at 10:35am
Can you upload a test case reproducing this behavior? (preferably against NorthwindIB)
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down