public Groups[] GroupList(WhereObjects oWhere = null) { return(Command <ObjectResult>("load_objects", new ObjectRequest <Groups, WhereObjects>() { where = oWhere }).groups); }
public Users[] UserList(WhereObjects oWhere = null) { return(Command <ObjectResult>("load_objects", new ObjectRequest <Users, WhereObjects>() { where = oWhere }).users); }
public long Count <T>(WhereObjects oWhere = null) { CheckSession(); ObjectResult result = Command <ObjectResult>("load_objects", new ObjectRequest <T, WhereObjects>() { fields = new string[] { "COUNT(*)" }, where = oWhere }); Type tpT = typeof(T); Type tpR = result.GetType(); object[] itens = (object[])tpR.GetField(tpT.Name.ToLower()).GetValue(result); return(((GenericCount)itens[0]).Count); }
// Somente para monstar o Where é necessário a derivação, mas será usado sempre para padronização // https://msdn.microsoft.com/en-us/library/d5x73970.aspx //private static WhereObjects WhereByObject<T>(long nID) where T : GenericObject, new() //{ // return WhereByObject<T>(new T() { id = nID }); //} public static WhereObjects WhereByObject <T>(T item) where T : GenericItem { // Cria a instancia do Tipo especifico, e define o ID para montar a busca por ID string cName = item.GetType().Name.ToLower(); FieldInfo fi = typeof(WhereObjects).GetField(cName); if (fi == null) { throw new NotSupportedException("Não há suporte para o filtro: " + cName); } // Monta o filtro WhereObjects where = new WhereObjects(); fi.SetValue(where, item);// ID que será buscado return(where); }