public List <T> GetItems(SqlFilter filter) { string sql = BuildSelectSql(filter); //KeyValuePair<string, object>[] arrayParameter = Parameters.ToArray(); //build couchbase key //string[] strParms = Parameters.Values.Select(p => { // if (p.SqlDbType == SqlDbType.Int) // return p.ParameterName + "=" + p.SqlValue.ToString(); // else // return p.ParameterName + "=\"" + p.SqlValue.ToString()+"\""; //}).ToArray(); //string key = !string.IsNullOrEmpty(filter.Identiy) ? filter.Identiy : typeof(T).Name + "_" + MD5Class.GetMD5ValueUTF8(sql) + "_" + string.Join(",", strParms); //CouchbaseClient client = CouchbaseHelper.CreateInstance(); //if (filter.ForceRefresh || (!string.IsNullOrEmpty(RequestContext.Current.request["reloadcache"]) && RequestContext.Current.request["reloadcache"] == "1")) //{ // client.Remove(key); //} //if (!string.IsNullOrEmpty(filter.CacheKey)) // key = filter.CacheKey; //if (client.KeyExists(key)) // list = client.Get<List<T>>(key); //else CouchbaseHelper helper = new CouchbaseHelper("default"); List <T> list = helper.Query <T>(sql, Parameters); //if (list != null) //{ // foreach (T to in list) // { // LateBind(filter.Binds, to); // } // if (filter.CacheLevel >0) // { // client.Store(StoreMode.Set, key, list, TransCacheLevel(filter.CacheLevel)); // } //} return(list); }
public Info GetItemsInfo(SqlFilter filter) { string sql = BuildSelectCountSql(filter); CouchbaseHelper helper = new CouchbaseHelper("default"); List <Info> list = helper.Query <Info>(sql, Parameters); Info info = list[0]; return(info); }