How are result DataTable see my example.

Posts   
 
    
Posts: 2
Joined: 20-Sep-2008
# Posted on: 25-Sep-2008 22:47:34   

Hi,

I Search variuos examples abaout this, but i try write my program and reveived msg wrong 'could not found adaper' or EntityView2.

When is library in my project exist this class?

my code : using System; using System.Collections.Generic; using System.Text; using System.Data;

using Gestor.CollectionClasses; using Gestor.DaoClasses; using Gestor.EntityClasses; using Gestor.FactoryClasses; using Gestor.HelperClasses; using Gestor.RelationClasses; using Gestor.StoredProcedureCallerClasses;

namespace cl_dbGestor { public class clsusuario { public SusuarioEntity obj_susuario; public int CodeRet;

    public clsusuario()
    {
        obj_susuario = null;
        CodeRet = 0;
    }
    public DataTable Consulta(int IDUsuario)
    {
        DataTable result = new DataTable();
        SusuarioCollection usuario = new SusuarioCollection(new SusuarioEntityFactory());
        adapter.FetchEntityCollection(usuario, null); // fetch all users           <==== Wrong  What is... using above namespace, i write all class the my project Gestor
        EntityView2 <SusuarioEntity> owners = new EntityView2<SusuarioEntity>(
                usuario, (usuarioFields.ID == IDUsuario));

        return result;

            //usuarioView = usuario.DefaultView;

        /*
        using(DataAccessAdapter adapter = new DataAccessAdapter())
        {
            adapter.FetchEntityCollection(usuario, null);
        }
        DataTable ret_tabela = new DataTable();
        IEntityFields2 campos = usuario.EntityFactoryToUse.CreateFields();
            //collection.EntityFactoryToUse.CreateFields();
         */     
        // EntityView2 usuarioIDView = new EntityView2( usuario,(SusuarioFields.ID == IDUsuario), null );
        // create projection of these customers of just the city and the customerid.
        // for that, define 2 propertyprojectors, one for each field to project
        /*
        ArrayList propertyProjectors= new ArrayList();
        propertyProjectors.Add( new EntityPropertyProjector( CustomerFields.City, "City" ) );
        propertyProjectors.Add( new EntityPropertyProjector( CustomerFields.CustomerId, "CustomerID" ) );

        // create the actual projection.
        usuarioIDView.CreateProjection( propertyProjectors, projectionResults );
        return projectionResults;
       }
         */
    }
}

}

Erros :

Error 1 The name 'adapter' does not exist in the current context F:\2008\publicinetpub\Estudos_Iniciados_SET2008\dbGestor\LLBLGen Pro Projects\Projetos\cl_dbGestor-rcp-software\clsusuario.cs 31 13 cl_dbGestor

other errror :

Error 1 The type or namespace name 'EntityView2' could not be found (are you missing a using directive or an assembly reference?) F:\2008\publicinetpub\Estudos_Iniciados_SET2008\dbGestor\LLBLGen Pro Projects\Projetos\cl_dbGestor-rcp-software\clsusuario.cs 31 13 cl_dbGestor

Thanks for you help.

sorry,my english is no good.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Sep-2008 10:11:45   

From your namespaces, I see that you are using SelfServicing template set, though at your user code you are using the methods of Adapter template set. So that's why you get the compilation errors.

For SelfServicing, your code should look like (see this manual example):

public DataTable Consulta(int IDUsuario)
{
    // fetch the collection
    SusuarioCollection usuario = new SusuarioCollection();
    usuario.GetMulti(null);

    // create the view
    EntityView<CustomerEntity> usuarioView = new EntityView<SusuarioEntity>(usuario, (usuarioFields.ID == IDUsuario), null);


    // create projection of these usuarios of just the xxx and the yyy.
    // for that, define 2 propertyprojectors, one for each field to project
    List<IEntityPropertyProjector> propertyProjectors = new List<IEntityPropertyProjector>();

    propertyProjectors.Add(new EntityPropertyProjector(SusuarioFields.Xxx, "xxx"));
    propertyProjectors.Add(new EntityPropertyProjector(SusuarioFields.Yyy, "yyy"));

    // create the actual projection
    DataTable projectionResults = new DataTable();
    usuarioView.CreateProjection(propertyProjectors, projectionResults);

    return projectionResults;
}

Also, What is intent of your method? I think that could be a little more optimal (fetch only the needed entities, not all records).

P.S.: next time, please post this kind of questions at "Generated code" forum wink

David Elizondo | LLBLGen Support Team