public IEnumerable <R_FoodTemplate> GetFoodTemplateListAdvancedSearch( string name , string description , string foodCategory , int?calories , System.DateTime?averageExpirationTimeFrom , System.DateTime?averageExpirationTimeTo , bool?liquid , bool?needsRefrigeration , bool?active ) { IEnumerable <R_FoodTemplate> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_FoodTemplate") .Where("IsDeleted = 0" + (name != null ? " and Name like '%" + name + "%'" : "") + (description != null ? " and Description like '%" + description + "%'" : "") + (foodCategory != null ? " and FoodCategory like '%" + foodCategory + "%'" : "") + (calories != null ? " and Calories like '%" + calories + "%'" : "") + (averageExpirationTimeFrom != null ? " and AverageExpirationTime >= '" + averageExpirationTimeFrom.Value.ToShortDateString() + "'" : "") + (averageExpirationTimeTo != null ? " and AverageExpirationTime <= '" + averageExpirationTimeTo.Value.ToShortDateString() + "'" : "") + (liquid != null ? " and Liquid = " + (liquid == true ? "1" : "0") : "") + (needsRefrigeration != null ? " and NeedsRefrigeration = " + (needsRefrigeration == true ? "1" : "0") : "") + (active != null ? " and Active = " + (active == true ? "1" : "0") : "") ) ; results = R_FoodTemplate.Query(sql); return(results); }
public IEnumerable <R_FoodTemplate> GetFoodTemplates() { IEnumerable <R_FoodTemplate> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_FoodTemplate") .Where("IsDeleted = 0") ; results = R_FoodTemplate.Query(sql); return(results); }