LINQ and looping

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

    #1

    LINQ and looping

    I have a SQL/Server table with a big int field that represents individual
    bit settngs. I'd like to use LINQ to iterate through that table, and
    bit-wise OR the contents of that field. It could be done, I know, by first
    retrieving the records, and then doing the ORing in a subsequent ForEach
    loop, but can it be done in a single LINQ query?
    If so, could you give me some idea of what that code would look like?
    Thanks,
    Ben


    bf001-no-spam-@furino.org

  • Frans Bouma [C# MVP]

    #2
    Re: LINQ and looping

    Ben wrote:
    I have a SQL/Server table with a big int field that represents
    individual bit settngs. I'd like to use LINQ to iterate through that
    table, and bit-wise OR the contents of that field. It could be done, I
    know, by first retrieving the records, and then doing the ORing in a
    subsequent ForEach loop, but can it be done in a single LINQ query?
    If so, could you give me some idea of what that code would look like?
    I don't know of any SQL construct which would offer that kind of
    functionality. Other than that, you really have to specify which linq
    provider you're using to produce the queries as linq constructs aren't
    converted to DB queries out of the box.

    FB

    --
    ------------------------------------------------------------------------
    Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
    LLBLGen Pro website: http://www.llblgen.com
    My .NET blog: http://weblogs.asp.net/fbouma
    Microsoft MVP (C#)
    ------------------------------------------------------------------------

    Comment

    Working...