Hi, I have a really big project with more than 200 Entity classes and I am doing all the database access via direct connection.
Good thing is that I kept my database access layer separate in a project and that project would be referenced from WCF service.
public bool Insert()
{
try
{
dc = new LinqDataContext1();
dc.Connection.Open();
using (dc.Transaction = dc.Connection.BeginTransaction())
{
dc.InsertPayee(1, PayeeID, PayeeName, StreetAddress, City, State.StateID, ZipCode, PhoneNumber, EmailAddress, Notes, (Carrier == null ? null : Carrier.CarrierID), IsActive, GlobalModels.Register.RegisterID);
dc.Transaction.Commit();
return true;
}
}
catch
{
throw;
}
finally
{
if (dc.Connection.State == ConnectionState.Open)
{
dc.Connection.Close();
}
}
}
public LinqDataContext1(string p_ConnectionString = "")
{
if (string.IsNullOrWhiteSpace(p_ConnectionString) == false)
{
connectionString = p_ConnectionString;
}
else
{
connectionString = GlobalModels.conString;
}
Connection = new MySqlConnection(connectionString);
}
Currently every client application keeps it's database connection string in global variable but in case of WCF service I would have to send a new connection string every time I call Payee.Insert(). My question is that could it cause any problem in future when there are lots of clients calling same service method and multiple database queries are executed and what are the things I should be careful about when working in WCF?
What I have tried:
I have added reference to existing database access project to WCF service application.