Hi all!
Which is the best way to detect if the field in:
Db.Where<T>(field, value);
doesn’t exists?
Can I try-catch the exception otherwise?
Thank you.
Hi all!
Which is the best way to detect if the field in:
Db.Where<T>(field, value);
doesn’t exists?
Can I try-catch the exception otherwise?
Thank you.
OrmLite doesn’t provide a formal API to access a tables schema.
What behavior did you get when trying to access a non-existent field?
It rise an Sql.Exception that I can catch with try-catch; I just want to know if there were better way to test a valid field.
It’s dependent on each RDBMS, the only attempt at a common solution across major RDBMS’s is the INFORMATION_SCHEMA view: https://en.wikipedia.org/wiki/Information_schema
You can also access the Schema using the ADO.NET GetSchemaTable API: http://stackoverflow.com/a/12161051/85785
But these aren’t formal API’s in OrmLite. You can use custom SQL API’s to query INFORMATION_SCHEMA
or access the underlying ADO.NET Connection with:
var sqlConn = (SqlConnection) db.ToDbConnection();