asp.net - I can't get my static class working with a Generic List -
i have static class needs pass generic list of strings function using integer index list in class. problem static class doesn't have list collect , don't have proper index access class in function passed to. class, calling code, , receiving function below.
my class:
public class querycontainer { public static querycontainer instance = new querycontainer(); private int _id; private string _query = ""; private int _searchid; public querycontainer() { } public string query { { if (instance != null) return instance._query; else return ""; } set { _query = value; _id =+ 1; } } public int id { { return _id; } } public int searchid { set { _searchid = value; } { return _searchid; } } }
the calling code:
public int getaccountsortbyaccountcode(int account) { int id = 0; querycontainer.instance.query = "select ac_sort_order lkup_account_codes ac_code = " + account.tostring(); return convert.toint32(executescaler(id)); }
the function static class passed to:
public int getaccountsortbyaccountcode(int account) { int id = 0; querycontainer.instance.query = "select ac_sort_order lkup_account_codes ac_code = " + account.tostring(); return convert.toint32(executescaler(id)); }
the function
protected object executescaler(int id) { object returnvalue = null; if (!_iserror) { if (_trace) { dotrace("tamis.data.loader.executescalar", querycontainer.instance.query); } if (_connection == null || _connection.state == connectionstate.closed) { openconnection(); } dbcommand command = _provider.createcommand(); command.connection = _connection; { command.commandtext = querycontainer.instance.query; command.commandtype = commandtype.text; if (_usetransaction) { command.transaction = _transaction; } try { returnvalue = command.executescalar(); } catch (exception ex) { if (ex entrypointnotfoundexception) throw ex; //if (_usetransaction == true) //_transaction.rollback(); rollback(); logbll bll = new logbll(); bll.writeerrorlog(ex); _iserror = true; } { if ((!keepalive && _connection.state == connectionstate.open) || _iserror == true) { closeconnection(); } } } } else { returnvalue = -1; } return returnvalue; }
you using querycontainer singleton.
in asp.net, receives multiple requests different users. not way construct dynamic query.
basically, doing requests use same querycontainer instance. don't think want.
the bottom line not use static in scenario.
Comments
Post a Comment