Toggle

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    Toggle

    Hello,

    I need to set the property IsActive = false for all records but one
    which has FileID = id

    database.Files. Select(p =p.FileID != id)

    I am selecting the records ... I just don't know how to change the
    IsActive of all this records to false.

    If possible using lambda.

    Thanks,
    Miguel
  • shapper

    #2
    Re: Toggle

    On Nov 18, 11:25 pm, shapper <mdmo...@gmail. comwrote:
    Hello,
    >
    I need to set the property IsActive = false for all records but one
    which has FileID = id
    >
    database.Files. Select(p =p.FileID != id)
    >
    I am selecting the records ... I just don't know how to change the
    IsActive of all this records to false.
    >
    If possible using lambda.
    >
    Thanks,
    Miguel
    I also tried:
    database.Files. Where(p =p.FileID != id).Select(p =p.IsActive =
    false);

    But I get an error:
    An expression tree may not contain an assignment operator

    Comment

    • Peter Duniho

      #3
      Re: Toggle

      On Tue, 18 Nov 2008 15:25:31 -0800, shapper <mdmoura@gmail. comwrote:
      Hello,
      >
      I need to set the property IsActive = false for all records but one
      which has FileID = id
      >
      database.Files. Select(p =p.FileID != id)
      >
      I am selecting the records ... I just don't know how to change the
      IsActive of all this records to false.
      >
      If possible using lambda.
      Not directly, no. For some reason, there's no "ForEach()" method in the
      Enumerable class.

      But, you can certainly just write a foreach() loop and do it explicitly.

      Pete

      Comment

      • shapper

        #4
        Re: Toggle

        On Nov 18, 11:45 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
        wrote:
        On Tue, 18 Nov 2008 15:25:31 -0800, shapper <mdmo...@gmail. comwrote:
        Hello,
        >
        I need to set the property IsActive = false for all records but one
        which has FileID = id
        >
        database.Files. Select(p =p.FileID != id)
        >
        I am selecting the records ... I just don't know how to change the
        IsActive of all this records to false.
        >
        If possible using lambda.
        >
        Not directly, no.  For some reason, there's no "ForEach()" method in the  
        Enumerable class.
        >
        But, you can certainly just write a foreach() loop and do it explicitly.
        >
        Pete
        Thank You Pete,
        Miguel

        Comment

        Working...