I use EntitySpaces for all of my Database related coding. As a sole developer I don't have time to sit and write the SQL for each and every application I write, so using a generator such as ES Suites me down to the ground and saves me days, if not weeks, of time.
I generally write a series of helper classes for each of the tables that my application utilises. The issue I have is that I don't really know the best way to handle any SQL Timeouts or failed connections, apart from stick a Try-catch around each method that deals with returning data.
In EntitySpaces the SQL Connection is built and executed only when I run any kind of CRUD command.
For example:
public TblUserCollection GetCollection()
{
TblUserCollection collection = new TblUserCollection();
collection.Query.Where(collection.Query.CompanyId == CompanyId);
collection.Query.OrderBy(collection.Query.FullName, esOrderByDirection.Ascending);
collection.Query.Load();
return collection;
}
This method is called when my helper class is told to assign the user list of a certain company to a ComboBox. The method then calls this and I assign the data to the list. I've got about 30 of these dotted around, all called GetCollection() in table specific helper classes.
Aside from just writing the method as:
public TblUserCollection GetCollection()
{
try
{
TblUserCollection collection = new TblUserCollection();
collection.Query.Where(collection.Query.CompanyId == CompanyId);
collection.Query.OrderBy(collection.Query.FullName, esOrderByDirection.Ascending);
collection.Query.Load();
return collection;
}
catch (System.Data.SqlClient.SqlException ex)
{
//
}
}
What else can I do?