Created
August 4, 2008 21:40
-
-
Save ebello/3978 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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