Hi,Dumb newbie question :-)

Posts   
 
    
Posts: 3
Joined: 19-May-2005
# Posted on: 01-Sep-2005 09:53:46   

Hi,

Been dropped in the deepend a bit here @ work being almost brand new to .NET! Anyway, I just need a pointer to how to fetch a row based on a column other than the PK, i.e. I've got an object called UserEntity and just want to get the details back based on the column UseCode.

Now I'm sure the How To section makes sense when you've more experience in .NET, but

Dim filter As New PredicateExpression()
filter.Add(PredicateFactory.CompareValue(YourEntityFieldIndex.Field, ComparisonOperator.Equal, 3))

What do I use in the YourEntityFieldIndex value here?

Thanks, and take pity on me flushed

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 01-Sep-2005 10:28:04   

The index of the entity you want to fetch. simple_smile

Say I want to fetch a customer, and I want to use a filter on companyname, which isn't the PK. I then do:


Dim filter As New PredicateExpression()
filter.Add(PredicateFactory.CompareValue(CustomerFieldIndex.CompanyName, ComparisonOperator.Equal, 3))

The enum is defined in the ConstantsEnums.vb file which is in the root of your namespace so you have to add an Imports yourrootnamespacegoeshere at the top of your file.

Frans Bouma | Lead developer LLBLGen Pro