0

I'm using the DbCommand from the EnterpriseLibrary. I have two methods which get same formated select from the database. So the DataReader looks same but, I'm executing other procedures.

My question is: is it a good idea is move to one method executing DbCommand and data reading from DataReader like this:

public Dictionary<Guid,List<string>> GetCurrentLoginData()
{
   // here is maked command and private method is called
}
public Dictionary<Guid,List<string>> GetSpecificLoginData(string login)
{
   // here is maked command and private method is called
}

// method which is called from both public methods
private Dictionary<Guid,List<string>> GetLoginData(DbCommand command)
{
   // here is code to executeCommand and data reading
}

Or maybe there is a better way? My other way is to move only the data reading to other method.

Thanks for answers, I hope this will help me.

reuben
  • 3,360
  • 23
  • 28
szkra
  • 1,423
  • 2
  • 14
  • 21

1 Answers1

1

I don't see anything bad with this approach. You are moving common functionality into the GetLoginData method, which is good practice, and the public methods have meaningful names and proper signatures.

Konamiman
  • 49,681
  • 17
  • 108
  • 138
  • Ok, but if I would change this signature and insert to this private method DataReader and return type with be the same then You will say that's ok too ?? And it's too good practice? – szkra Dec 15 '09 at 12:05