"In this it might have to do with the fact that it is using function mapping (it is a TVF), but I am not sure.
var products = from p in db.ProductsByName(""%ich%"")
where p.Category == Categories.Food
select p;
I think this kind of cast tends to prevent SQL from using indexes.
"
This item was migrated from the DevDiv work item tracking system [ID=371803].
Comments: Sounds great. Some additional information from the language team: > At the language level, the semantics of equality on short values is actually to fall back to the int equality operator. That is probably why the conversions are inserted... Maybe we could optimize them away ... This made me think that we could try an approach in which we just remove casts that seem superfluous during the translation phase or later, e.g. there general rule could be that if there is a comparison operator between two things wrapped in casts but the underlying elements being compared are of the same type, then it should be safe to remove the casts. We should also look at how this interacts with nullability. By the way it seems that this could possibly fix a few other issues like [#823](https://entityframework.codeplex.com/workitem/823) and even possibly [#187](https://entityframework.codeplex.com/workitem/187).
var products = from p in db.ProductsByName(""%ich%"")
where p.Category == Categories.Food
select p;
I think this kind of cast tends to prevent SQL from using indexes.
"
This item was migrated from the DevDiv work item tracking system [ID=371803].
Comments: Sounds great. Some additional information from the language team: > At the language level, the semantics of equality on short values is actually to fall back to the int equality operator. That is probably why the conversions are inserted... Maybe we could optimize them away ... This made me think that we could try an approach in which we just remove casts that seem superfluous during the translation phase or later, e.g. there general rule could be that if there is a comparison operator between two things wrapped in casts but the underlying elements being compared are of the same type, then it should be safe to remove the casts. We should also look at how this interacts with nullability. By the way it seems that this could possibly fix a few other issues like [#823](https://entityframework.codeplex.com/workitem/823) and even possibly [#187](https://entityframework.codeplex.com/workitem/187).