Retrieve the contents of a Typed View as a DataReader

Posts   
 
    
siegemos
User
Posts: 47
Joined: 25-Jun-2007
# Posted on: 15-Jan-2010 17:38:25   

Hi,

How do I get records from a Typed View as a DataReader? I don't want to use TypedView.Fill as I want to populate my own objects.

Apologies if this is clearly written somewhere in the documentation somewhere, I can't find it.

I'm back in the dark ages using LLBLGen 2.5.

Thanks.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-Jan-2010 19:52:10   

Please give a try to this.

David Elizondo | LLBLGen Support Team
siegemos
User
Posts: 47
Joined: 25-Jun-2007
# Posted on: 18-Jan-2010 11:30:15   

Thanks for your response but the link you've mentioned just tells me how to get a DataReader from a dynamic list (where I can build the field list from the entity fields). What I'm after is how to get a DataReader from a view rather than a table. With a view, I have no entity fields with which to build a field list.

I could do this...

        
        TypedListDAO dao = new TypedListDAO();
        IDbCommand cmd = new SqlCommand("SELECT * FROM view_MyView");
        IRetrievalQuery query = new RetrievalQuery(cmd);
        return dao.GetAsDataReader(null, query, CommandBehavior.CloseConnection);

But it's not ideal. Is this my only option?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 18-Jan-2010 15:27:59   

A TypedView has its own Fields too, same as an entity. So you can build a DynamicList out of it.

Also you can use the TypedView Fields collection directly in the GetAsDataReader() call.

siegemos
User
Posts: 47
Joined: 25-Jun-2007
# Posted on: 18-Jan-2010 17:47:44   

Yes you can, sorry I completely missed the fact that view fields were available in the same way as table fields. Thanks for the help.