Is it possible to receive some information about the used database?
E.g. Database exists, Database version, instance name, SQL Version, SQL Server Edition....
Thank you,
Manuel
1 Answer, 1 is accepted
0
Boyan
Telerik team
answered on 14 Mar 2014, 03:27 PM
Hi Manuel,
You could expose information about the backend you are working through the context extending it the following way:
public partial class EntitiesModel
{
public Telerik.OpenAccess.BackendConfiguration.BackendInformation GetDatabaseInformation()
{
var scope = this.GetScope();
var backendInfo = scope.Database.BackendConfiguration.BackendInfo;
return backendInfo;
}
}
Additionally, through the GetSchemaHandler() method of a context you could get a schema handling instance which will tell you if a database exists and will help you to create/update the database schema by executing and generating DDL scripts. Please refer to this documentation article for more information on how to handle schema migration.
As an alternative, through the ADO apiTelerik Data Access allows you to execute any custom script you wish. You could use that to execute queries which return information about the database instance provided that you have sufficient rights. For example, you could get the instance name (or other information you are interested in) in the following way:
var context = new EntitiesModel();
var result = context.ExecuteScalar<string>("SELECT @@servername");
Please note that this may require backend specific code which probably will not work if you change the backend.
Should you have any further questions, please let us know.
Regards,
Boyan
Telerik
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.