|
Demo Version
|
|
Download and try for yourself a fully working demo version, including sample apps and documentation. The only limitation is that the demo version only works inside the debugger.
|
|
Subscribe
|
|
Get It All for $50 USD:
WebPortal, ORMapper,
Source Code, All Updates
|
|
User Login
|
|
|
|
|
|
Wilson ORMapper Forums : Other Databases : Postgres
|
|
| 2/19/2006 8:06:09 AM |
hello,
i tried to use postgres and worm but i am not able to connect.
here is a code snippet:
string mappingFile = "mapping.xml";
string connectString = "DRIVER={PostgreSQL};SERVER=localhost;DATABASE=sports;User ID=postgres;Password=bosie;";
CustomProvider provider = new CustomProvider("Npgsql", "Npgsql.NpgsqlConnection", "Npgsql.NpgsqlDataAdapter");
provider.StartDelimiter = "["; provider.EndDelimiter = "]";
provider.ParameterPrefix = ":";
provider.IdentityQuery = "SELECT currval('{1}_{0}_seq')";
provider.SelectPageQuery = "SELECT * LIMIT {0} OFFSET {1}";
ObjectSpace os = new ObjectSpace(mappingFile, connectString, provider);
ObjectSet<Test> _s = os.GetObjectSet<Test>(string.Empty);
it throws an exception that the connectionstring is invalid.
i have used that connectionstring with ado.net succesfully, so how do i setup worm for postgres ?
thank you very much
thomas |
| 2/19/2006 2:47:43 PM |
Hi Thomas:
I don't think the connection string should have the part that specifies "DRIVER={PostgreSQL}". That would be necessary if you were using OleDb, but it should not be when you are using the PostgreSql provider. So my question for you is when you say that connection string has worked, did it work with OleDb or the PostgreSql provider?
Thanks, Paul Wilson |
| 2/19/2006 3:53:28 PM |
hi paul,
i figured it out, it seemed it was a problem with npgsql, i had an older version in use.
funny stuff is, when i do pass a rather clean provider to the objectspace everything works perfectly (at least for my short test, i dont know how it is when i go deeper)
CustomProvider provider = new CustomProvider("Npgsql", "Npgsql.NpgsqlConnection", "Npgsql.NpgsqlDataAdapter");
ObjectSpace os = new ObjectSpace(mappingFile, connectionString, provider);
works.
however, when i set the properties you suggested in the other postgres-thread, i get an syntax error
ERROR: 42601: syntax error at or near "["
so please tell me, what properties do i have to set exactly to make the customprovider work smoothly for WORM?
by the way, the DRIVER=Postgresql isnt a problem at all.
thank you very much
thomas |
| 2/19/2006 5:45:40 PM |
Hi Thomas:
The purpose of the delimiters is to automatically handle table and field names that have spaces, reserved words, etc. The ANSI standard for such delimiters is the double-quote, and most databases do support that one way or the other, although it may not be the default, so try setting these to that instead:
provider.StartDelimiter = "\"";
provider.EndDelimiter = "\"";
Its really very hard for me to ever give conclusive instructions on how to setup most databases though, because they are often very configurable, and sometimes the providers change the defaults also. So I give what I have either found to be the default, or what I was able to determined worked for me -- but it may not be the setting of your database install or provider. This is also one reason why I leave this configurable instead of making it hard-coded like many other O/R Mappers have done.
Thanks, Paul Wilson |
|
|