protected static Dictionary <string, object> MapQuery(OdooContext context, OdooQuery query = null) { if (query == null && (context == null || !context.Any())) { return(null); } var result = new Dictionary <string, object>(); if (context != null && context.Any()) { result["context"] = context; } if (query == null) { return(result); } if (query.Limit.HasValue) { result["limit"] = query.Limit; } if (!string.IsNullOrWhiteSpace(query.Order)) { result["order"] = query.Order; } if (query.Offset.HasValue) { result["offset"] = query.Offset; } if (query.ReturnFields.Any()) { result["fields"] = query.ReturnFields.ToArray(); } if (!result.Any()) { return(null); } return(result); }
internal OdooQueryBuilder(OdooClient odooClient) : base() { _odooClient = odooClient; _query = new OdooQuery <T>(); }
public static OdooRequestModel SearchCount(OdooConfig config, int uid, string tableName, OdooQuery query = null, OdooContext context = null) { var param = new OdooRequestParams(config.ApiUrlJson, "object", "execute_kw", config.DbName, uid, config.Password, tableName, OdooOperation.SearchCount, GetRequestFilters(query), MapQuery(context, query)); return(new OdooRequestModel(param)); }
public static OdooRequestModel Read(OdooConfig config, int uid, string tableName, long[] ids, OdooQuery query = null, OdooContext context = null) { var param = new OdooRequestParams(config.ApiUrlJson, "object", "execute_kw", config.DbName, uid, config.Password, tableName, OdooOperation.Read, ids, MapQuery(context, query)); return(new OdooRequestModel(param)); }
protected static object[] GetRequestFilters(OdooQuery query = null) { return(query != null && query.Filters.Count > 0 ? new object[] { query.Filters.ToArray() } : new object[] { new object[] { } }); }
public static OdooRequestModel SearchRead(OdooConfig config, int uid, string tableName, OdooQuery query = null) { var param = new OdooRequestParams(config.ApiUrlJson, "object", "execute", config.DbName, uid, config.Password, tableName, OdooOperation.SearchRead, query?.GetRequestFilters(), query?.GetRequestFields(), query?.Offset, query?.Limit, query?.Order); return(new OdooRequestModel(param)); }