Anyone looking for some extra help on a programming project? I guess my full potential isn't being used at my current company so I'm have a bit of free time left over and am willing to lend it out. Drop me a mail if you need some help on something,new or old and i'll try add my 2c.
Bardy85
Posts
-
Programming projects -
Returning a parameter from a stored procYou need to get C# to excute your stored procedure then get the return variable and store it in NewAgentID. I use Microsoft Database access application block. So in c# the code would look somehting like this.
int NewAgentId = int.Parse(SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "Call for Stored Procedure").ToString());
-
EXCEPTION HANDLINGYou could try the following.
ConsoleKeyInfo ck = Console.ReadKey();
char Key = ck.KeyChar; -
Application Info and Error loggingLookup TracerX. Very good at logging Messages/Exceptions. You can also set the level of the logs.
-
Which is more correct?Thanks, I've just started implementing the : List. Don't know why I didn't think about it before. Thanks again for the help. :)
-
Which is more correct?Thanks for the help.
-
Which is more correct?Thanks, I do have quite a few records, anywhere up to 10000. I do quite a few checks on the List though, every day I get a bulk file of employees and check if the employee exists, if he does I need to check if any of his details have changed. (Every single field) I think one select of all the data and then data lookups would be faster then 10000 selects?
-
Which is more correct?Thanks, nice way of doing it. If you wanted to initialize the list once at start of your application and then be able to call it through out the scope of you app, how would you do it?
-
Which is more correct?Employees can have the same name though. I do see what you saying, but problem lies more on the way I build my classes. Having most of the list static so I can access them from anywhere. I don't think this is right though. Well it is right but proberly doesn't follow best practises.
-
Which is more correct?Example 1.
public class Employees
{
public static List ListEmployees;public static void FillEmployees() { ListEmployees = FillFromSQL(); }
}
class Program
{
static void Main(string[] args)
{
Employees.FillEmployees();
}
}Then whenever I need to access the list of employee objects I can just call Employees.ListEmployees.Find(e => e.Name == "Mike"); I can call this anywhere in my scope because is static. Or Example 2
public class Employees
{
private List ListEmployees;public void FillEmployees() { ListEmployees = FillFromSQL(); } public void FindEmployee(Predicate e) { return ListEmployees.Find(e); }
}
class Program
{
Employees employees;static void Main(string\[\] args) { employees = new Employees(); employees.FillEmployees(); }
}
Any help would be much appreciated. Or if you have a better way of doing it that would be a great help.
-
Holding data in memoryAgreed. I think then i'll have to sort the List on the field thats going to be most used. Then I can sort the list and use a binary search on that criterium. If I have to search on any other field I'll just have to use the standard search, which I think is a bubble search. Anyway thanks.
-
Holding data in memoryMos Dan - Lucian wrote:
Try using StoredProcs instead of string commands => significant speed gains.
I've read that StoredProcs arn't quicker then normal queries. Have I read wrong? http://betav.com/blog/billva/2006/05/are_stored_procedures_faster_t.html[^]
-
Holding data in memoryI currently do implement IComparable, but don't sort the list of Objects or Use BinarySearch. I guess this would speed up things up. Only problem I see is that BinarySearch does not take a Predicate as an arguement, and I use Predicates to find a matching object. Do you know another way arround this? For example my Employee object has quite a few fields and I don't always want to search where the whole employee object matches, only maybe ID or Lastname, thats why I like using Predicates. In your above example you can only search on Name. I guess you can't do a binary search and then use Predicate to find that specific employee object, because of the way a binary sort works. Anyway thanks for you comments. They have shed some light on my problems. Thanks.
-
Holding data in memoryThe employee record doesn't hold much, about 15 fields, like Name, Surname, Id, etc. There can be up to about 5000 or so Employee records. The app is batch application that runs every 5min. I guess I'm not too worried about holding the data in memory, more about how I'm holding this data. For EG the below class is how I hold and Edit the data. My methods always seem to be public and I don't think that this is the right way of doing it. Enen though it works.
public class EMPLOYEE
{
/// <summary>
/// list of EMPLOYEEs
/// </summary>
public static List<Tools.DB.OL.Xtime.EMPLOYEE> listEMPLOYEE = new List<Tools.DB.OL.Xtime.EMPLOYEE>();#region Methods /// <summary> /// Fills the EMPLOYEE. /// </summary> public static void FillEMPLOYEE() { listEMPLOYEE = GenericFactory<Tools.DB.OL.Xtime.EMPLOYEE>.FillList("SELECT \* FROM EMPLOYEE"); } /// <summary> /// Inserts the specified new EMPLOYEE. /// </summary> /// <param name="employee">The employee.</param> public static void InsertEMPLOYEE(Tools.DB.OL.Xtime.EMPLOYEE employee) { GenericFactory<Tools.DB.OL.Xtime.EMPLOYEE>.Insert(ref listEMPLOYEE, employee); } /// <summary> /// Updates the specified new EMPLOYEE. /// </summary> /// <param name="employee">The employee.</param> public static void UpdateEMPLOYEE(Tools.DB.OL.Xtime.EMPLOYEE employee) { GenericFactory<Tools.DB.OL.Xtime.EMPLOYEE>.Update(ref listEMPLOYEE, employee); } /// <summary> /// Deletes the EMPLOYEE. /// </summary> /// <param name="employee">The employee.</param> public static void DeleteEMPLOYEE(Tools.DB.OL.Xtime.EMPLOYEE employee) { GenericFactory<Tools.DB.OL.Xtime.EMPLOYEE>.Delete(ref listEMPLOYEE, employee); } #endregion #region SQL Queries public static Tools.DB.OL.Xtime.EMPLOYEE FindEMPLOYEE(Predicate<Tools.DB.OL.Xtime.EMPLOYEE> p) { Tools.DB.OL.Xtime.EMPLOYEE employee = new Tools.DB.OL.Xtime.EMPLOYEE(); if (listEMPLOYEE.Exists(p)) { employee = listEMPLOYEE.Find(p); } return employee;
-
Holding data in memoryCurrently the way I work with data from SQL is I store in the records of a table in a list in memory. I normally have a class with static methods, and at the begining of my program I would normally fill this list
Employees.FillEmployees(); //Fill all employees from employee table into List
Then anywhere in my program I can work with this Employee data, by using a set of static methods, or just call the List directly. This employee data isn't often changed so I'm not worried about it changing while I'm working with it. I'm just not sure that holding this data in memory is the best option. I know that it does take up a lot more memory, but then the access time is much quicker,then say doing a select query every time I needed the data. Any thoughs on this would be appreciated. Thanks
-
Nullable types??True. What ever is best for the job. Simple. easy. For some reason when I code, I sit for hours wasting time, trying to find the best way foward. I know there are always a handfull of ways to accomplish a given task. I'm just trying to find the "best",most effecient,simplest solution. Maybe that it. Time. Every ms counts. Oh well. Think it's just monday driving me up the wall. Thanks anyway.
-
Nullable types??Well then. When are they good and when are they bad? Is that better?
-
Nullable types??Oh so noble of me. But there is some noble-ness in the underlying madness of the obvious. Ok, enough about the s. Just wondering if I should change my codeing to include the nullable type. It's like I've come to a cross road. Start using then from here on in and ill be stuck with them. It's not like something small either. It's like creating a new standard that ill be using from now on. Busy rewriteing my helper utility. Wondering if I should use them. ?? Help. ?? HElp ?? HELp ?? HELP
-
Nullable types??Nullable or Not. That is the question. Are they good or are they bad? What are YOUR thoughts?
-
Best Method to Instantiate a ClassSo basically Method 2. I was kinda going with that. Thanks.