New Posts New Posts RSS Feed: Question on converting EntityList to List
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Question on converting EntityList to List

 Post Reply Post Reply
Author
Customer View Drop Down
Senior Member
Senior Member
Avatar
User Submitted Questions to Support

Joined: 30-May-2007
Location: United States
Posts: 260
Post Options Post Options   Quote Customer Quote  Post ReplyReply Direct Link To This Post Topic: Question on converting EntityList to List
    Posted: 12-Jul-2007 at 3:43pm

I would just like to ask if converting from System.Collections.IList to IdeaBlade.Persistence.EntityList? Because I’m having problems when filtering records using the FindAll method of Entitylist that returns an IList object. Is it possible to return an EntityList object instead of the IList??

 

Here is the method where I need to convert to EntityList.

 

public EntityList<GSC.Entities.PayrollTrxLines> GetPayrollTrxLinesByEmployee(string code, EntityList<GSC.Entities.PayrollTrxLines> AlltrxLines)

        {

 

            Predicate<PayrollTrxLines> filter = delegate(GSC.Entities.PayrollTrxLines attribute)

            {

                if (attribute.EmployeeCode != null

                    && attribute.EmployeeCode.Equals(code))

                    return true;

 

                return false;

            };

 

            System.Collections.Generic.List<GSC.Entities.PayrollTrxLines> filterObj = AlltrxLines.FindAll(filter);

 

            if (filterObj.Count > 0)

                return filterObj as EntityList<GSC.Entities.PayrollTrxLines>;

 

            return null;

        }

 

Back to Top
IdeaBlade View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 30-May-2007
Location: United States
Posts: 353
Post Options Post Options   Quote IdeaBlade Quote  Post ReplyReply Direct Link To This Post Posted: 12-Jul-2007 at 3:44pm

You must use List, not EntityList.

Try using a List<PayrollTrxLines> instead of an EntityList<PayrollTrxLines> as in this example from Reference Help

 

     PersistenceManager pm = PersistenceManager.DefaultManager;

 

     // Retrieve all customers.

     EntityList<Customer> allCustomers = pm.GetEntities<Customer>();

     System.Diagnostics.Debug.WriteLine(allCustomers.Count.ToString());

 

     // Define find criteria - this looks for companies beginning with letter 'A'.

     Predicate<Customer> filter = delegate(Customer pCustomer) {

       return pCustomer.CompanyName.StartsWith("A");

     };

 

     // Find a subset of customers.

     List<Customer> AListCustomers = allCustomers.FindAll(filter);

     Console.WriteLine(AListCustomers.Count.ToString());

 

 

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down