C
cody
Jon said:It's also worth bearing in mind that although the equality operators
aren't generated for you, ValueType.Equals does a memberwise
comparison, using a fast bit comparison where appropriate and calling
Equals on each field otherwise. It's not fast, but it works.
In other words, if you don't care about performance then implementing
== and != can be as simple as calling Equals.
(While I'm on the topic of == and !=, can anyone think of any reason
why you'd ever implement them to return a type other than bool? I
wasn't even aware it could be done until a few days ago.)
Jon
I have create a Data access layer, something like DLinq.
I created a class Expression where operator== yields a new compound
expression:
public static Expression operator==(Expression a, Expression b)
{
return GenerateBinaryExpression("=", a, b);
}
So the syntax allows calls like that:
ProjektstundenTable ps = Tables.Projektstunden;
SelectQuery query = new SelectQuery();
query.From(ps);
query.Select(query.Functions.Sum(ps.fpStunden));
// note that this ==, not beeing a string is NOT evaluated in code
// but instead, it is internally converted to an expression string and
// sent to the database!
query.Where(ps.ProjektRessourcenID==this.ID);