//ALL MEAL PHOTOS public List <MealPhoto> GetAllMealPhotos() { List <MealPhoto> mealPhotosList = null; Action <IDataReader, short> singleRecMapper = delegate(IDataReader reader, short set) { MealPhoto singleItem = new MealPhoto(); int startingIndex = 0; //startingOrdinal singleItem.Id = reader.GetSafeInt32(startingIndex++); singleItem.PhotoId = reader.GetSafeInt32(startingIndex++); singleItem.MealId = reader.GetSafeInt32(startingIndex++); singleItem.UserId = reader.GetSafeInt32(startingIndex++); singleItem.DateAdded = reader.GetSafeDateTime(startingIndex++); singleItem.DateModified = reader.GetSafeDateTime(startingIndex++); if (mealPhotosList == null) { mealPhotosList = new List <MealPhoto>(); } mealPhotosList.Add(singleItem); }; Action <SqlParameterCollection> inputParamDelegate = null; _dataProvider.ExecuteCmd("dbo.MealPhotos_SelectAll", inputParamDelegate, singleRecMapper); return(mealPhotosList); }
public MealPhoto GetMealPhoto(int id) { MealPhoto myMealPhoto = null; Action <IDataReader, short> singleRecMapper = delegate(IDataReader reader, short set) { MealPhoto singleItem = new MealPhoto(); int startingIndex = 0; //startingOrdinal singleItem.Id = reader.GetSafeInt32(startingIndex++); singleItem.PhotoId = reader.GetSafeInt32(startingIndex++); singleItem.MealId = reader.GetSafeInt32(startingIndex++); singleItem.UserId = reader.GetSafeInt32(startingIndex++); singleItem.DateAdded = reader.GetSafeDateTime(startingIndex++); singleItem.DateModified = reader.GetSafeDateTime(startingIndex++); myMealPhoto = singleItem; }; Action <SqlParameterCollection> inputParamDelegate = delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@Id", id); }; _dataProvider.ExecuteCmd("dbo.MealPhotos_SelectById", inputParamDelegate, singleRecMapper); return(myMealPhoto); }
//ALL MEAL PHOTOS WITHIN RADIUS public List <MealPhoto> GetPhotos(List <int> mealIds) { List <MealPhoto> mealSearchResultsPhotoList = null; Action <SqlParameterCollection> inputParamDelegate = delegate(SqlParameterCollection paramCollection) { SqlParameter itemParameter = new SqlParameter("@MealIds", System.Data.SqlDbType.Structured); if (mealIds != null && mealIds.Any()) { MealIdTable mealIdsTbl = new MealIdTable(mealIds); itemParameter.Value = mealIdsTbl; } paramCollection.Add(itemParameter); }; Action <IDataReader, short> singleRecMapper = delegate(IDataReader reader, short set) { MealPhoto singleItem = new MealPhoto(); int startingIndex = 0; //startingOrdinal singleItem.Id = reader.GetSafeInt32(startingIndex++); singleItem.PhotoId = reader.GetSafeInt32(startingIndex++); singleItem.MealId = reader.GetSafeInt32(startingIndex++); singleItem.UserId = reader.GetSafeInt32(startingIndex++); singleItem.DateAdded = reader.GetSafeDateTime(startingIndex++); singleItem.DateModified = reader.GetSafeDateTime(startingIndex++); singleItem.FileName = reader.GetSafeString(startingIndex++); singleItem.FileTypeId = reader.GetSafeInt32(startingIndex++); if (mealSearchResultsPhotoList == null) { mealSearchResultsPhotoList = new List <MealPhoto>(); } mealSearchResultsPhotoList.Add(singleItem); }; _dataProvider.ExecuteCmd("dbo.MealPhotos_SelectByMealIds", inputParamDelegate, singleRecMapper); return(mealSearchResultsPhotoList); }