Exception message is On data context type there is a top IQueryable property whose element type is not an entity type

我们两清 提交于 2019-12-12 09:41:38

问题


im bulding my WCFDataService hosted in IIS 7, im going to use Reflection Provider as data source provider. my sample work if i keep the entity type definition in the same assembly where i defined the service, but dosen't work if i move the entity type to another referenced assembly with following error

"server encountered an error processing the request. The exception message is 'On data context type 'EntityContainer', there is a top IQueryable property 'Cats' whose element type is not an entity type"

Service

public class WcfDataService1 : DataService<EntityContainer>
    {

        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("Cats", EntitySetRights.AllRead);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;

        }
    }

Entity Container

public class EntityContainer
    {
        public IQueryable<Cat> Cats
        {
            get
            {
                var s = new List<Cat>();
                var c1 = new Cat {Id = 1, Name = "Fufi"};
                var c2 = new Cat {Id = 1, Name = "Felix"};
                s.Add(c1);
                s.Add(c2);
                return s.AsQueryable();
            }
        }

    }

Entity type

[DataServiceKey("Id")]
public  class Cat 
{
     public int Id { get; set; }

     public string Name { get; set; }
}

now as i said above everithing work if i keep the class Cat together with the other code, but i got an error if i move the Cat to a referenced assembly

What im missing?


回答1:


After 2 hours and strong head ache i found the problem by myself, i was referencing Microsoft.Data.Services.Client in my service and System.Data.Services.Client in the referenced project library where i was going to move the entity type. Hope my post can help someone else. Thank you



来源:https://stackoverflow.com/questions/26864806/exception-message-is-on-data-context-type-there-is-a-top-iqueryable-property-who

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!