I think the error there lies in the way you are trying to compare the TKey generic. Since TKey is a complex type, the == operator has to be explicitly implemented in order to make this comparison. Now with the TKey generic, there is no guarantee that it is.
Perhaps there is another generic constraint you can place on TKey to ensure that there is a comparison method available?
Yes I think this is the crux of the problem and hence why I tried to constrain TKey to value types where == should be available. Clearly this isn't working as I intended though. – Joshua Hayes Nov 4 '10 at 6:12 Constraining to a struct doesn't ensure value the equality operator is in play.
For lack of a better solution you could write an evaluator function that reflects the common properties and if they all match then you have equality. Or you can serialize both and do string comparison. Not elegant solutions either of em though.
– Slappy Nov 4 '10 at 6:37 msdn.microsoft. Com/en-us/library/ms173110. Aspx – Slappy Nov 4 '10 at 6:41 Thanks for the update slappy.
You are correct about the struct contraint. It was a long short. I cannot believe there wouldn't be a way to achieve what works fine in LinqToSql, in the entity framework.
However, as for constraining to value types I believe its not actually possible. So I'm a bit stumped here... – Joshua Hayes Nov 4 '10 at 11:00.
Below is the relevant code for the FindById method I am having problems with in EntityFramework. This FindById(...) works fine with LinqToSql but does not work in EntityFramework 4. Unable to create a constant value of type 'System.
Only primitive types ('such as Int32, String, and Guid') are supported in this context.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.