Skip to content

Instantly share code, notes, and snippets.

@ebello
Created August 4, 2008 21:40
Show Gist options
  • Save ebello/3978 to your computer and use it in GitHub Desktop.
Save ebello/3978 to your computer and use it in GitHub Desktop.
public static List<T> LoadLookup<T, U>(IDataReader reader) where T : ILookup<U>, new()
{
List<T> list = new List<T>();
try
{
while (reader.Read())
{
T lookup = new T();
lookup.ID = (U)reader["ID"];
lookup.Name = (string)reader["Name"];
list.Add(lookup);
}
return list;
}
finally
{
reader.Close();
}
}
// to call
IDataReader reader = SqlProvider.Instance().GetAlliances();
return DataHelper.LoadLookup<Alliance, byte>(reader);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment