Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > FAQ > Generated code FAQ> Is there a Find method in the Entity collections?
 

Pages: 1
Generated code FAQ
Is there a Find method in the Entity collections?
Page:1/1 

  Print all messages in this thread  
Poster Message
Aglaia
LLBLGen Pro Team



Location:
Scheveningen, The Netherlands
Joined on:
07-Sep-2003 21:16:00
Posted:
534 posts
# Posted on: 21-Aug-2007 13:20:58.  
Question:
I want to look up an entity in a collection with read entities. Is there a Find method in the Entity collections?

Solution:
You can find entities easily with in-memory filtering on an entitycollection. Take for example the following code, which finds the CustomerEntity with the PK "CHOPS" in the customer collection. This works for both Adapter and SelfServicing. It will use the DefaultView object for this.

Code:

// C#
CustomerCollection customers = new CustomerCollection();
// get all customers
customers.GetMulti(null);
IEntityView view = customers.DefaultView;
// filter view
view.Filter = (CustomerFields.CustomerId == "CHOPS");
// get a reference to the entity to find:
CustomerEntity toFind = view[0];

VB.NET
Dim customers As New CustomerCollection()
' get all customers
customers.GetMulti(Nothing)
Dim view As IEntityView = customers.DefaultView
' filter view
view.Filter = New FieldCompareValuePredicate(CustomerFields.CustomerId, _
ComparisonOperator.Equals, "CHOPS")
' get a reference to the entity to find:
CustomerEntity toFind = view(0)
Aglaia Kuipers, The LLBLGen Pro Team

Join the LLBLGen Pro support team!
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.