Using Expressions with EntityCollections

Posts   
 
    
simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 07-Feb-2007 12:14:38   

Is it possible to use Expressions with EntityCollections. I want to do something like this, but can't get the syntax right.

    EntityCollection orderDetails = new EntityCollection();
    MyExpression myExpression= new MyExpression (DocumentFields.CreatedDate);
    orderDetails**.Fields**[DocumentFields.CreatedDate.Name.ToString()].SetExpression(myExpression);

Or is the only way to do it like this:

        ResultsetFields fields = new ResultsetFields(5);
        fields.DefineField(DocumentFields.Queue, 0);
        MyExpression myExpression = new MyExpression (DocumentFields.CreatedDate);
        fields[0].SetExpression(myExpression);
Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Feb-2007 16:38:10   

Would you please explain what exactly that you want to do? I mean what is the SQL query that you want to execute? How does your expression look like?

Which version of LLBLGen Pro are you using?

simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 07-Feb-2007 16:48:56   

The expression I am writing is to execute XQuery against a SQL Server 2005 XML column.

So the SQL I am trying to write is something like:

select xmlcolumn.query('/root/mynode') from myTable where someOtherColumn <10

The expression is working fine against a single entity, but I am trying to SETEXPRESSION against the column for an EntityCollection.

I am using v2.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Feb-2007 17:06:10   

I think you should use a Dynamic List and then you might project the resultset back to an entityCollection.

simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 07-Feb-2007 17:15:22   

How can I cast a DataTable back into an EntityCollection?

Is there a reason why this is so, or has the SetExpression method just not been implemented on an EntityCollection yet?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Feb-2007 18:39:42   

How can I cast a DataTable back into an EntityCollection?

Please consult the v.2.0 manual: "Using the generated code -> Adapter/SelfServicing -> Fetching DataReaders and projections"

We will get back to you on the 2nd question ASAP.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 07-Feb-2007 19:04:18   

The fetched data in the select list using the XQuery, is that data forming an entity? I have the feeling it's not, (i.e it's a list, though not an entity as known in table/view form). Using an expression in an entitycollection can be done though. Please see the example in this article (where I modify the factory to add a new field, you can also use this to set an expression on a field). http://weblogs.asp.net/fbouma/archive/2006/06/09/LLBLGen-Pro-v2.0-with-ASP.NET-2.0.aspx

Frans Bouma | Lead developer LLBLGen Pro