Juan Pablo Gomez
Juan Pablo Gomez

Reputation: 5524

linq using timestamp column to filter

I have a sqlserver table that has a timestamp column, I'm trying tou use it for filter a linq query like this:

byte[] filtroTimeStamp = SessionBag.Current.mesasTimeStamp; 

var ubicAbiertas = from uA in db.TableA
    select uA;

ubicAbiertas = ubicAbiertas.Where(
     y => y.BitAbierta == true 
   & y.BitBloqueada == true 
   & y.TimeStampUltimoCambio == filtroTimeStamp);

When I try this way it shows an error: operator & can't be applied to operands of type bool and byte[]

How can I do to use Byte[] values as a filter of linq Query?

Upvotes: 1

Views: 333

Answers (2)

Omar
Omar

Reputation: 16623

You have to use the && operator which performs a logical-AND:

ubicAbiertas = ubicAbiertas.Where(y => y.BitAbierta == true 
                                  && y.BitBloqueada == true
                                  && y.TimeStampUltimoCambio == filtroTimeStamp);

Upvotes: 2

dove
dove

Reputation: 20674

That should be && (two not one ampersand), e.g.

&& y.BitBloqueada == true 

Upvotes: 4

Related Questions