I'm experimenting with using AtomsFramework for O/R Mapping on an existing database and I'm stuck on how to represent a one to many relationship between my tables.
For example, I have a 1:n relationship between the Items and Categories tables, in the database this is done through an Items_Categories table to store the Item_ID with the corresponding Category_ID as necessary. (This is an MSSQL DB).
However, looking over the reference in the tutorials (is there any more detailed documentation on the xml specification?), there doesn't seem to be a way to specify the Items_Categories table.
Can anyone give me some pointers?
TIA.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Lack of documentation is a problem at the moment and I am working on it (there's a users guide in CVS starting to take shape)
In regards to mapping relationships to databases the normal method is as follows:
A (1:n) B - Table B records hold a reference to table A records by storing key values.
A (m:n) B - Table A and B as normal, and an extra table used for saving the associations (TableAB).
In your case you are using the Items_Categories table to manage the association so you are actually using a many-to-many association (even if one side only ever has one record).
The latest version of the code supports a simplified association mapping for many-to-many assocations, whereas earlier versions required two one-to-many associations and a helper object.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-04-12
Hi Richard,
Thanks for the info! I've got a copy from the CVS and I'm trying to compile it - however, where do I get all of the required assemblies such as Npgsql, IBM.Data.Informix, etc.?
Also, if I remove all of those assemblies (I only want MSSQL support anyway), no matter what I include or reference in my project I always get the exception-
Error Initializing Database Provider CMsSqlDatabase. Error is: File or assembly name CMsSqlDatabase, or one of its dependencies, was not found.
Thanks,
Phil
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The providers for postgresql, informix and others you can ignore. If you have those databases you'd have the ADO.NET providers and would be able to compile them.
I don't include them in CVS since versions change and I don't want to have to track each and every version.
The error you are getting relates to the <database /> tag in the XML file.
If you look at the tag you will see a provider="xxx" attribute. This provider name is the name of the .DLL to use to access the database. You need something like AF_MSSQL.DLL or similar.
If you are upgrading from v2.0 then you would have class="CMsSqlDatabase" (which is my guess). Change the XML mapping to provider="AF_MSSQL.DLL" and make sure the .DLL is copied to the applications run directory and everything should work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-04-13
Thanks, that worked great!
However, I had to specify "bin\af_mssql.dll" for it to be able to find the assembly.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-04-14
Just to correct myself there, I have to specify the full path to the assembly for it to find it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm experimenting with using AtomsFramework for O/R Mapping on an existing database and I'm stuck on how to represent a one to many relationship between my tables.
For example, I have a 1:n relationship between the Items and Categories tables, in the database this is done through an Items_Categories table to store the Item_ID with the corresponding Category_ID as necessary. (This is an MSSQL DB).
However, looking over the reference in the tutorials (is there any more detailed documentation on the xml specification?), there doesn't seem to be a way to specify the Items_Categories table.
Can anyone give me some pointers?
TIA.
Hi Phil
Lack of documentation is a problem at the moment and I am working on it (there's a users guide in CVS starting to take shape)
In regards to mapping relationships to databases the normal method is as follows:
A (1:n) B - Table B records hold a reference to table A records by storing key values.
A (m:n) B - Table A and B as normal, and an extra table used for saving the associations (TableAB).
In your case you are using the Items_Categories table to manage the association so you are actually using a many-to-many association (even if one side only ever has one record).
The latest version of the code supports a simplified association mapping for many-to-many assocations, whereas earlier versions required two one-to-many associations and a helper object.
This forum message http://sourceforge.net/forum/forum.php?thread_id=1226895&forum_id=208149
should explain how the new method works. You will need the code from the v2_1 branch of CVS in order to use this functionality.
- Richard.
Hi Richard,
Thanks for the info! I've got a copy from the CVS and I'm trying to compile it - however, where do I get all of the required assemblies such as Npgsql, IBM.Data.Informix, etc.?
Also, if I remove all of those assemblies (I only want MSSQL support anyway), no matter what I include or reference in my project I always get the exception-
Error Initializing Database Provider CMsSqlDatabase. Error is: File or assembly name CMsSqlDatabase, or one of its dependencies, was not found.
Thanks,
Phil
The providers for postgresql, informix and others you can ignore. If you have those databases you'd have the ADO.NET providers and would be able to compile them.
I don't include them in CVS since versions change and I don't want to have to track each and every version.
The error you are getting relates to the <database /> tag in the XML file.
If you look at the tag you will see a provider="xxx" attribute. This provider name is the name of the .DLL to use to access the database. You need something like AF_MSSQL.DLL or similar.
If you are upgrading from v2.0 then you would have class="CMsSqlDatabase" (which is my guess). Change the XML mapping to provider="AF_MSSQL.DLL" and make sure the .DLL is copied to the applications run directory and everything should work.
Thanks, that worked great!
However, I had to specify "bin\af_mssql.dll" for it to be able to find the assembly.
Just to correct myself there, I have to specify the full path to the assembly for it to find it.
Relative paths will also work. They will be started at wherever the .exe file is located.