none
syncronize two collection RRS feed

  • Question

  • hy.
    I have a class Ctask.
    Ctask have a field IdProjectTask as int.
    I have 2 collection of object Ctask:
    ILCtaskProject and ILCtaskDb as Ilist<Ctask>.
    I must sincronize the ILCtaskDb with ILCtaskProject:
    if a Ctask object in ILCtaskProject not exist(the IdProjectTask not exist in all object in the ILCtaskDb )in ILCtaskDb i should insert the ctask object in db.
    What is the best solution ?
    thanks.
    Thursday, December 27, 2007 9:43 PM

All replies

  • why do you need 2 collections instead of just one that handles project and db?

     giuseppe500 wrote:
    hy.
    I have a class Ctask.
    Ctask have a field IdProjectTask as int.
    I have 2 collection of object Ctask:
    ILCtaskProject and ILCtaskDb as Ilist<Ctask>.
    I must sincronize the ILCtaskDb with ILCtaskProject:
    if a Ctask object in ILCtaskProject not exist(the IdProjectTask not exist in all object in the ILCtaskDb )in ILCtaskDb i should insert the ctask object in db.
    What is the best solution ?
    thanks.
    Thursday, December 27, 2007 9:59 PM
  • but so i understand i do this more easy , i get the object ctask from project and i see if is contained in the collection of db , if not is contained i add it else i go next.
    But how i know if the object is contained in the collection?
    so i have the id that is unique , but how modify the collection for match the id in the contains method?
    thanks

    Thursday, December 27, 2007 10:38 PM
  • Maybe you can use Dictionary<id, dbTask> instead of/in addition to List<dbTask>, this way it's much easier to check if it contains the id.

     giuseppe500 wrote:
    but so i understand i do this more easy , i get the object ctask from project and i see if is contained in the collection of db , if not is contained i add it else i go next.
    But how i know if the object is contained in the collection?
    so i have the id that is unique , but how modify the collection for match the id in the contains method?
    thanks

    Friday, December 28, 2007 2:20 PM