public IList<MakeCountInfo> GetMakeCounts() { //Decalaring MakesInfo division object collection IList<MakeCountInfo> MakesInfoIList = new List<MakeCountInfo>(); string spNameString = string.Empty; //Setting Connection //Global.INSTANCE_NAME = strCurrentConn; IDataReader MakesInfoDataReader = null; //Connect to the database Database dbDatabase = DatabaseFactory.CreateDatabase(Global.INSTANCE_NAME); //Assign stored procedure name spNameString = "[USP_GetAllMakeCountsMobile]"; DbCommand dbCommand = null; try { //Set stored procedure to the command object dbCommand = dbDatabase.GetStoredProcCommand(spNameString); dbDatabase.AddInParameter(dbCommand, "@makeID", DbType.Int64, 0); //Executing stored procedure MakesInfoDataReader = dbDatabase.ExecuteReader(dbCommand); while (MakesInfoDataReader.Read()) { //Assign values to the MakesInfo object list MakeCountInfo ObjMakesInfo_Info = new MakeCountInfo(); AssignMakesInfoList(MakesInfoDataReader, ObjMakesInfo_Info); MakesInfoIList.Add(ObjMakesInfo_Info); } } catch (Exception ex) { } finally { MakesInfoDataReader.Close(); } return MakesInfoIList; }
private void AssignMakesInfoList(IDataReader MakesInfoDataReader, MakeCountInfo objMakesInfo) { try { objMakesInfo.AASuccess = "Success"; objMakesInfo.MakeID = int.Parse(MakesInfoDataReader["makeID"].ToString()); objMakesInfo.Make = Convert.ToString(MakesInfoDataReader["make"]); objMakesInfo.MakeCount = int.Parse(MakesInfoDataReader["makeCount"].ToString()); } catch (Exception ex) { } }