nreco / data

Fast DB-independent DAL for .NET Core: abstract queries, SQL commands builder, schema-less data access, POCO mapping (micro-ORM).
https://www.nrecosite.com/dalc_net.aspx
MIT License
184 stars 39 forks source link

table schema name #29

Closed wendt88 closed 7 years ago

wendt88 commented 7 years ago

Is it possible to select/update/insert on tables with custom schema name and how? Can't find nothing about that

VitaliyMF commented 7 years ago

Implicit conversion between string and QTable that occurs in code like new Query("contacts.c") treats evertything after last '.' as table alias; this query is converted to the following SQL:

SELECT * FROM contacts c

If you don't want to specify table alias and want to specify table schema you can do that in the following way: new Query( new QTable("myschema.contacts", null) )

When schema-qualified name is specified in DbDataAdapter methods that accept table name as string nothing special is needed, for example:

DbAdapter.Insert("main.companies", new Dictionary<string,object>() {
    {"title", "Test Inc"},
    {"country", "Norway"},
    {"logo_image", null}
}) );
DbAdapter.Update("main.companies", companyRS);  // update recordset

Please note that there was a bug with handling schema-qualified name in Insert/Update/Delete methods that already fixed (don't forget to update to version 1.0.1 that was published today).