Unable to cast Exception Q2 2012 SP2

13 posts, 0 answers
  1. Eloy Paredes
    Eloy Paredes avatar
    4 posts
    Member since:
    Nov 2005

    Posted 01 Sep 2012 Link to this post

    I have an application developed with:
    • Windows 7, 64 bits
    • Visual Studio 2010, .NET Framework 4.0
    • PostgreSQL 9.1
    • Telerik OpenAccess Q2 2012 Free Edition
    this application work pefectly.

    I change my plataform to:
    • Windows 8, 64 bits
    • Visual Studio 2012, .NET Framework 4.0
    • PostgreSQL 9.1
    • Telerik OpenAccess Q2 2012 SP2 Free Edition
    I migrate application to this plataform, and update all reference, but when run i see this exception:

    Unable to cast object of type 'OpenAccessRuntime.Relational.RelationalNewObjectOID' to type 'System.Collections.ICollection'

    there any way to solve this error?

    thanks in advance and sorry for my bad English
  2. Ralph Waldenmaier
    Admin
    Ralph Waldenmaier avatar
    202 posts

    Posted 03 Sep 2012 Link to this post

    Hello Eloy Paredes,

    This is a known bug which will be fixed with the next version. This only occurs if you create an object and assign a reference to the object, before the object is added to the context. If you add the reference on the object after your object is added to the context, then this error will not occur.
    See the following script as example for your workaround:

    // this will fail
    var refrnce = new SomeOtherClass();
    var obj = new SomeClass(){ Id = 123, Reference = refrnce };
    ctx.Add(obj) // will fail
     
    // this will not fail
    var obj = new SomeClass(){ Id = 123 };
    ctx.Add(obj) // will not fail
    var refrnce = new SomeOtherClass();
    obj.Reference = refrnce;

    Please accept my apologies for any inconvenience caused.
    I hope this information is helpful for you.
    Feel free to ask if you have any other question.
     All the best,
    Ralph
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  3. DevCraft banner
  4. Adrian
    Adrian  avatar
    15 posts
    Member since:
    Dec 2010

    Posted 03 Sep 2012 Link to this post

    Hello
    I am the same problem.I think it is a problem in OpenAccess.
    If you have 1 class with releation 1:n
    and in your code is like this:
     Achitare.FmTipDocumente = model.FmTipuriDocumentes.Where(p => p.NumeScurt == "CHIT").FirstOrDefault();
    Openaccess generate this error when you add this object to model.
    One temporary solution for you is this:
     Achitare.FkTipDocumente = (model.FmTipuriDocumentes.Where(p => p.NumeScurt == "CHIT").FirstOrDefault()).Pk;
  5. Eloy Paredes
    Eloy Paredes avatar
    4 posts
    Member since:
    Nov 2005

    Posted 03 Sep 2012 Link to this post

    Thanks for the replay.

    Now we just wait for the next version.

    as my code is somewhat complicated by the changes you pose I get another error.
  6. Ralph Waldenmaier
    Admin
    Ralph Waldenmaier avatar
    202 posts

    Posted 04 Sep 2012 Link to this post

    Hello Eloy Paredes,

    The next version will have the needed bits to work with the approach you had before.

    @Neagoe: Have you tried to set your references when your object is managed by the context? You shouldn't get an error then as described earlier.

    Do come back if you need further assistance.

    Regards,
    Ralph
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  7. Ian
    Ian avatar
    21 posts
    Member since:
    Apr 2011

    Posted 16 Sep 2012 Link to this post

    Hi,
    This error is killing us. Is there an internal build available with the fix in it?
    ian
  8. Ralph Waldenmaier
    Admin
    Ralph Waldenmaier avatar
    202 posts

    Posted 17 Sep 2012 Link to this post

    Hi Ian,

    The bug is already fixed and will be available with the next internal build to be released soon. I will keep you updated once the internal build is released.

    Please accept my apologies for the inconvenience caused so far.

    Regards,
    Ralph
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  9. Myth
    Myth avatar
    54 posts
    Member since:
    Jan 2010

    Posted 21 Sep 2012 Link to this post

    Any update on when the next internal update will be released? I'm also troubled by this bug so I removed the new version and reinstalled my previous.
  10. Ralph Waldenmaier
    Admin
    Ralph Waldenmaier avatar
    202 posts

    Posted 21 Sep 2012 Link to this post

    Hi Myth,

    The new build will be available soon. Most probably in a few days.
    I will keep you updated as soon as the update is released.

    Kind regards,
    Ralph
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  11. Mirco
    Mirco avatar
    2 posts
    Member since:
    Sep 2012

    Posted 24 Sep 2012 Link to this post

    Hello Ralph,
    same issue here: I have an object (let's say "order") with a classic foreing key reference (let's say "customer").
    "customer" is a non nullable external reference.

    I get the exception as soon as I add the "order" to the context using code below:

    Order newOrder = new Order();
    newOrder.Customer = GetCustomer("customerCode");
    model.OpenAccessContext.add(newOrder);

    We are in great hurry here ... 

    thanks

    PS I noticed an inconsistency in the OrmModel (.rlinq) file. There's a non-nullable field that is actually missing from the actual Class and from the database table. Updating the model from the database doesn't fix that.


    PPS NOW SOLVED
    ok I got it.
    FIRST I have to create the "order" object WITHOUT any reference to the CUSTOMER. 
    Then I have to add the ORDER to the Context
    Then I have to load the CUSTOMER from the context
    Then I have to add the ORDER to the CUSTOMERS.ORDERS collection

    Probably I were missing the IsManaged property of the relation in the designer
  12. Ralph Waldenmaier
    Admin
    Ralph Waldenmaier avatar
    202 posts

    Posted 24 Sep 2012 Link to this post

    Hello Mirco,

    the issue has been fixed with the latest internal build which is available for download since today.
    I hope your issue has been solved.

    Do come back if you have further questions. 

    Greetings,
    Ralph
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  13. Vinicius
    Vinicius avatar
    3 posts
    Member since:
    May 2012

    Posted 13 Oct 2012 Link to this post

    what´s link of the download?
  14. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 18 Oct 2012 Link to this post

    Hi,

    I would suggest you to directly download the Q3 2012 release of OpenAccess ORM which is now available on our site. You can access it either by Your Account -> Manage Products -> Free Products -> OpenAccess ORM, or you can just go the OpenAccess homepage and download it from there.


    All the best,
    Ivailo
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
Back to Top
DevCraft banner