I have a byte array in my Code First Entity Framework for SQL TimeStamps, mapping as given below:
[Column(TypeName = "timestamp")]
[MaxLength(8)]
[Timestamp]
public byte[] TimeStamps { get; set; }
The above property is equal to SQL server "timestamp" Data type in C#.
In SQL server I can compare "timestamp" easily as below...
SELECT * FROM tableName WHERE timestampsColumnName > 0x000000000017C1A2
Same thing I want to achieve in C# or Linq Query. Here I have written my Linq query, which is not working properly.
byte[] lastTimeStamp = someByteArrayValue;
lstCostCenter.Where(p => p.TimeStamps > lastTimeStamp);
I have also tried with BitConverter
to compare a two byte array which is also not working...
lstCostCenter.Where(p => BitConverter.ToInt64(p.TimeStamps, 0) > BitConverter.ToInt64(lastTimeStamp, 0));
How can I compare byte arrays in C# or Linq Query.
Note - I just do not want to compare two arrays normally like using SequenceEqual or any other methods which are just compare and return true or false. I want the comparison in Linq query with Greater than > or Less than < operator which gives proper data like SQL Server query.