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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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).
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....".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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!
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
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.
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
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....".
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.
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 ...