コード例 #1
0
 public Groups[] GroupList(WhereObjects oWhere = null)
 {
     return(Command <ObjectResult>("load_objects", new ObjectRequest <Groups, WhereObjects>()
     {
         where = oWhere
     }).groups);
 }
コード例 #2
0
 public Users[] UserList(WhereObjects oWhere = null)
 {
     return(Command <ObjectResult>("load_objects", new ObjectRequest <Users, WhereObjects>()
     {
         where = oWhere
     }).users);
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        // 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);
        }