Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var customers = new Dictionary<string, Customer>();
- While(sqlReader.Read())
- {
- // If you give the Customer object public properties you can initialize
- / like this. The class also requires an empty constructor. This is default if you don't add a constructor
- Customer customer = new Customer()
- {
- FirstName = sqlReader["FirstName"]?.ToString() ?? "",
- LastName = sqlReader["LastName"]?.ToString() ?? "",
- Vin = sqlReader["Vin"]?.ToString() ?? "",
- };
- customers.Add(customer.Vin.Trim().ToLower(), customer);
- }
- // Customer Class example (you may already know this)
- public class Customer
- {
- public string FirstName {get;set;}
- public string LastName {get;set;}
- public string Vin {get;set;}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement