Menu

relational mapping ...

T.Mo
2005-04-06
2013-03-07
  • T.Mo

    T.Mo - 2005-04-06

    i am new to AtomsFramework, but trying to upgrade my current project using AtomsFramework:)

    Here ask a very simple question. In ms sql server, we all know that we can do autodeletion/update by mapping different tables with foreign keys. Say, A Customer may have a few orders, and if this customer got deleted, all the orders shall be deleted automatically.

    How can I achieve this by using this framework? I dont want to use the ms sql server features to achieve this, as i may use another database.

     
    • T.Mo

      T.Mo - 2005-04-06

      I believe i have figured how.

      Now, another question. if i apply lazy loading to collections, how to load them when I need them?

      THanks!

       
    • Richard Banks

      Richard Banks - 2005-04-06

      Have a read of this previous forum topic:

      http://sourceforge.net/forum/forum.php?thread_id=1229818&forum_id=208150

      Let me know if you still have questions.

      - Richard

       
    • Nobody/Anonymous

      Many Thanks Richard! I do have some more questions:)

      Here comes one:

      While trying to use method CCursor.loadPersistentObject or loadObject in C#, i always have following error msg:

      Argument '1': cannot convert from 'ref Helper.DefSettings' to 'ref AToMSFramework.CPersistentObject'

      But what I see from online tutorial in your web site cant help me on this ... Please let me know which part goes wrong..

      My Code:

      defs = new DefSettings();
                          cursor.loadPersistentObject(ref defs);

      I also tried loadObject method. Give me same error.

       
      • Richard Banks

        Richard Banks - 2005-04-07

        You should definitely be using loadObject.  loadPersistentObject is meant to be an internal use method.

        Regardless your exception message is probably a good indicator...
        Argument '1': cannot convert from 'ref Helper.DefSettings' to 'ref AToMSFramework.CPersistentObject'

        Even though DefSettings inherits from CPersistentObject C# requires that you explicitly cast the object first (don't ask me why - I don't know).

        Try this:
        CPersistentObject cp;
        cp = defs;
        cursor.loadObject(ref cp);
        defs = (DefSettings) cp;

        - Richard

         
    • T.Mo

      T.Mo - 2005-04-07

      Ok, I modified my code as following:

      CPersistentObject objDf;
      defs = new DefSettings();
      objDf = defs;
      cursor.loadObject(ref objDf); // only one object.
      defs = (DefSettings)objDf;

      And i still got similar messages:
      The best overloaded method match for 'AToMSFramework.CCursor.loadObject(ref object)' has some invalid arguments
      Argument '1': cannot convert from 'ref AToMSFramework.CPersistentObject' to 'ref object'

      Cant pass the compiler! The only time i can get my code compiled is to use Object (not CPersistentObject!) to init a variable, and pass down as "ref myObj". However, when get into execution, the application will tell me "no mapping for Object class....".

       
    • Richard Banks

      Richard Banks - 2005-04-07

      I'll check it out - I always use VB, so my C# is a bit rusty.  It might take me a little bit to figure it out.

       
    • T.Mo

      T.Mo - 2005-04-07

      Finally, manage to solve it now. Get some hints from your reply just now.

      The working code:

      CPersistentObject objDf;
      defs = new DefSettings();
      objDf = defs;
      cursor.loadPersistentObject (ref objDf); // only one object.
      defs = (DefSettings)objDf;

      For C#, shall use loadPersistentObject  method, otherwise wont work. Maybe this is an illegal use of the framework ...

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.