1

Closed

TVF with Enum property

description

With your example:
[DbFunction("MyContext", "CustomersByZipCode")]
public IQueryable<Customer> CustomersByZipCode(string zipCode)
{
    var zipCodeParameter = zipCode != null ?
        new ObjectParameter("ZipCode", zipCode) :
        new ObjectParameter("ZipCode", typeof(string));

    return ((IObjectContextAdapter)this).ObjectContext
        .CreateQuery<Customer>(
            string.Format("[{0}].{1}", GetType().Name, 
                "[CustomersByZipCode](@ZipCode)"), zipCodeParameter);
}
If the Customer class contains a Enum property it gives the following error:
The underlying provider does not support the type 'EducationTypeEnum'.
[ArgumentException: The underlying provider does not support the type 'EducationTypeEnum'.]
   System.Data.Entity.SqlServer.SqlProviderManifest.GetStoreType(TypeUsage edmType) +295
   CodeFirstStoreFunctions.StoreFunctionBuilder.GetStorePrimitiveTypeUsage(TypeUsage typeUsage) +63
   CodeFirstStoreFunctions.StoreFunctionBuilder.<CreateReturnRowType>b__3(EdmMember m) +89
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +157
   System.Data.Entity.Core.Metadata.Edm.RowType.CheckProperties(IEnumerable`1 properties) +185
   System.Data.Entity.Core.Metadata.Edm.RowType..ctor(IEnumerable`1 properties, InitializerMetadata initializerMetadata) +68
   System.Data.Entity.Core.Metadata.Edm.RowType..ctor(IEnumerable`1 properties) +39
   System.Data.Entity.Core.Metadata.Edm.RowType.Create(IEnumerable`1 properties, IEnumerable`1 metadataProperties) +92
   CodeFirstStoreFunctions.StoreFunctionBuilder.CreateReturnRowType(String propertyName, EdmType edmType) +561
   CodeFirstStoreFunctions.StoreFunctionBuilder.CreateFunctionReturnParameters(FunctionDescriptor functionDescriptor) +200
   CodeFirstStoreFunctions.StoreFunctionBuilder.Create(FunctionDescriptor functionDescriptor) +303
   CodeFirstStoreFunctions.FunctionsConvention.Apply(EntityContainer item, DbModel model) +223
   System.Data.Entity.ModelConfiguration.Configuration.ModelConventionDispatcher.Dispatch(T item) +340
   System.Data.Entity.ModelConfiguration.Configuration.ModelConventionDispatcher.VisitEdmEntityContainer(EntityContainer item) +41
   System.Data.Entity.Edm.EdmModelVisitor.VisitCollection(IEnumerable`1 collection, Action`1 visitMethod) +204
   System.Data.Entity.Edm.EdmModelVisitor.VisitEntityContainers(IEnumerable`1 entityContainers) +89
   System.Data.Entity.Edm.EdmModelVisitor.VisitEdmModel(EdmModel item) +253
   System.Data.Entity.ModelConfiguration.Configuration.ModelConventionDispatcher.VisitEdmModel(EdmModel item) +54
   System.Data.Entity.ModelConfiguration.Configuration.ModelConventionDispatcher.Dispatch() +129
   System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.ApplyStoreModel(DbModel model) +136
   System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo) +587
   System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +103
   System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +143
   System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +171
   System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +566
   System.Data.Entity.Internal.InternalContext.Initialize() +31
   System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +39
   System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +137
   System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() +38
   System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() +108
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +369
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
Closed Aug 31, 2015 at 4:58 AM by moozzyk
Unable to repro

comments

moozzyk wrote Jan 7, 2015 at 6:21 AM

I added an enum property to the Customer type and updated the initializer and cannot reproduce this. Can you post the entire repro (including customer class, the enum type definition, initializer code etc.)? I assume you are using the latest available stable version.

Thanks,
Pawel