I have an entity called File, I created a partial class with a property on it.
I was able to use this property in regular constructors and other statements. But this property is not accepted in any linq statement.
I am getting the following exception.
Exception
The specified type member ‘FileStatus’ is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
Code
var fileEntry = from entry in context.ICFiles
where entry.FileName == FileName &&
entry.FileStatus == FileStatus.InProgress
select entry;
fileEntry.First().FileStatus = FileStatus.Completed;
// This is where I get the exception
Property Definition
public partial class ICFile
{
[DataMemberAttribute()]
public FileStatus FileStatus
{
get
{
return (FileStatus)this.Status;
}
set
{
this.Status = (int)value;
}
}
}
Right when I asked the question, I was left with the answer that @user1039947 has posted. However, that’s not the one I was expecting as an answer for this question.
I was looking for the ability of Entity framework to utilize the Enum completely. But eventually I figured out that Linq to Entity can’t recognize the Enums (it usually recognizes the entities through an attribute starting with Edm, like EdmTypeAttribute, EntityPropertyAttribute etc.)
Linq to Entity of Framework 4.0, has no way to accept the enums as entity object. However, the partial method serves us 80% what we might need from enum.
I have posted a blog with more detail on this.