EF SqlQuery tries to map object property, even though it's attributed [NotMapped]

Viewed 1283

I have a stored procedure that I execute with context.Database.SqlQuery<MyObject>("MyProc")

MyObject has a readonly property:

[NotMapped]
public bool IsSomething { get { return this.otherproperty == "something"; } }

So I get the error:

System.IndexOutOfRangeException: IsSomething at System.Data.ProviderBase.FieldNameLookup.GetOrdinal etc

Which is because MyProc doesn't have IsSomething in the result columns (I'm 100% sure that's probably the reason).

Shouldn't it just ignore it since it's [NotMapped]? Do I need to set something else for SqlQuery?

To make things even more weird, I only see it on production, from the logs of Stackify, and the page seems to load properly without any errors in the browser.

2 Answers
Related