public void Add(Store store) { using (var command = new CommandContext(context).Command) { //command.Transaction = context.Transaction; command.CommandText = "pr_Store_create"; command.CommandType = CommandType.StoredProcedure; command.AddParameter("@DistrictName", store.DistrictName); command.AddParameter("@IsActive", store.IsActive); using (var reader = command.ExecuteReader()) while (reader.Read()) { store.Load((int)reader["StoreId"], (string)reader["DistrictName"], (bool)reader["IsActive"]); } } }
public Store GetByDistrictName(string districtName) { using (var command = new CommandContext(context).Command) { command.CommandText = "pr_Store_get_byDistrictName"; command.CommandType = CommandType.StoredProcedure; command.AddParameter("@DistrictName", districtName); using (var reader = command.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { var store = new Store(); store.Load((int)reader["StoreId"], (string)reader["DistrictName"], (bool)reader["IsActive"]); return(store); } } return(null); } } }