Archive for October 2011

LINQ and Dynamic Query – Comparing DateTime value

October 20, 2011

In one of our development, we end up with the situation that needs to check the DateTime value in Dynamic LINQ query. Trying different ways out there and googling a bit, finally got some useful references that helped us to resolve the same

Hope, you would love reading!



TestEntities te = new TestEntities();

string dateString = “12/01/2010”;


Used the following overload for “.Where” :

# 1:

IQueryable<T>.Where(Expression<Func<State, bool>> predicate)

var dateTest = te.SiteLogs

.Where(String.Format(“it.TimeStamp >= DATETIME ‘{0}'”, Convert.ToDateTime(dateString).ToString(“yyyy-MM-dd HH:mm”)))



# 2:

IQueryable.Where(string predicate, params object[] values)

var dateTest1 = te.SiteLogs

.Where(“it.TimeStamp >= @0”,  Convert.ToDateTime(dateString))




In # 1,

  • We need to say the “Time” format also, that is compulsory. Otherwise it would throw an error as well.  And again, the syntax with “DATETIME” is wired 🙂
  • The resultant date format should be “yyyy-MM-dd “


In # 2,

Its clean and simple. I like this syntax. Here you can add any number of Params like @0, @1 & so on



Operator “===” / identity operator / Triple equal operator

October 10, 2011

What is Triple equal operator? Where, Why & When it’s used?

In general,

Double equal (==) is called equality operator

Tripe equal (===) is called identity operator

Here are few gotchas, you would love reading!

Where it’s used?

Seems that in PHP, RUBY (I haven’t played with them, but got to know through googling :)) & JavaScript

Why & When it’s used?

When we have a situation to check “both operands have the same value and are of the same type”.

Let’s see some examples in JavaScript:

‘1’ === ‘1’   // true – Same value and type

‘1’ === 1    // false – Same value but different type

‘1’ === true // false – Value and type are different

Equality operators also have their opposites 🙂

The non-identity operator ( !== ) returns true, where identity would return false.

‘1’ !== ‘1’   // false

‘1’ !==  1    // true

Then, is anything there in C#?

I don’t see the exact, but we have one, that helps to check for the same “instance” type, that’s it!

C# static method ReferenceEquals(obj1, obj2), helps to check same instance or reference equality.


Other useful references:

SaaS Vs. IaaS Vs. PaaS

October 9, 2011

I was just checking for SaaS and related. And got some extra stuffs like IaaS and PaaS too. That are all awesome!

Please check the following image, it speaks a lot!