internal void UseConnection(DbMethod method, bool write) { UseConnection((DbMethod <object>) delegate(IDbConnection connection) { method(connection); return(null); }, write); }
protected void Page_Load(object sender, EventArgs e) { if (Session["LoginId"] == null) { Response.Redirect("../Login"); } else { int id = DbMethod.GenerateId("ProjectId", "Project"); LblPojectId.Text = id.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["LoginId"] == null) { Response.Redirect("../Login"); } else { int id = DbMethod.GenerateId("questionId", "Forums"); qIdLbl.Text = id.ToString(); } }
public T UseConnection <T>(DbMethod <T> method, bool write) { IDbConnection theConnection; // Try to let any pending reads go through if we need to write, // since it locks everything. if (write) { DateTime start = DateTime.Now; while (workingConnections.Count > 0) { System.Threading.Thread.Sleep(1); if ((DateTime.Now - start).TotalSeconds >= 1) { // After a second, give up and go anyway. break; } } } lock (connections) { theConnection = connections.Find(delegate(IDbConnection c) { return(c.State == System.Data.ConnectionState.Open); }); connections.Remove(theConnection); } if (theConnection == null) { theConnection = CreateDbConnection(); } workingConnections.Add(theConnection); T result = method(theConnection); workingConnections.Remove(theConnection); lock (connections) { connections.Add(theConnection); } return(result); }
internal void UseConnection(DbMethod method) { UseConnection(method, false); }
internal T UseConnection <T> (DbMethod <T> method) { return(UseConnection(method, false)); }
public void UseConnection(DbMethod method) { UseConnection(method, false); }
public T UseConnection <T>(DbMethod <T> method) { return(UseConnection(method, false)); }