Please help, need small adjustment on existing code

Posts   
 
    
Joris
User
Posts: 2
Joined: 28-Nov-2012
# Posted on: 28-Nov-2012 12:03:43   

Hello,

I am not so familiar with the llblgen code, and I need to do an adjustment. The existing vb.net code that used llblgen objects is this:

If mbCol.Count = prodEnt.ManufacturingBillErp.Count Then...

The prodEnt is an article, and the ManufacturingBillERP table contains the partlist of that article. The mbCollection should have the same count.

Now the change that is required is this: It only should count the articles with the same bill of material number. For example, only the Partlist of BOM 77.

So I tried something

Dim filterBomNr As New PredicateExpression(New FieldCompareValuePredicate(BomNr, ComparisonOperator.Equal, 77)) If mbCol.Count = prodEnt.ManufacturingBillErp(filterBomNr).Count Then ...

But of course it doesn't work that way.

How can I do this please?

Best Regards,

Joris

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 28-Nov-2012 13:39:25   

Selfservicing or adapter? If you don't know, what's the type of mbCol? Is it EntityCollection(Of T) (==adapter) or ManufacturingBillingCollection or something (==selfservicing) ?

If you just want the count, and not all entities, just use a scalar fetch: http://www.llblgen.com/documentation/3.5/LLBLGen%20Pro%20RTF/hh_goto.htm#Using%20the%20generated%20code/gencode_expressionsaggregates.htm

Frans Bouma | Lead developer LLBLGen Pro
Joris
User
Posts: 2
Joined: 28-Nov-2012
# Posted on: 28-Nov-2012 14:49:45   

Hello,

Thanks for the reply. It is Selfservicing.

It would be best that I need the entities, because later in the code I get this:

For Each ent In prodEnt.ManufacturingBillErp If ent.BomNr = prReq.BomNr Then ' ent.Delete() End If

I inserted the If Then clause to solve it, but it would be better that I could do something like For Each ent in prodEnt.ManufacutringBillErp(prReq.BomNr).

But I assume this is not possible?

Joris

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Nov-2012 20:49:38   

First of all to filter a collection in memory, you can use Linq2Objects. Or using EntityViews