WCF没有返回服务端点

时间:2013-07-19 07:59:52

标签: wcf-data-services odata

我正在尝试从WCF数据服务返回实体列表。我没有使用实体框架,而是从Neo4j中提取数据并将其返回为Queryeable。如果我运行代码说没有为ObjectEntitiesService.svc找到url,我会收到404错误吗?

这是我的代码: 对象

[DataServiceKeyAttribute("Id")]
    public class ObjectEntity 
    {
        public string Id { get; set; }
        public string Name { get; set; }
        public string EntityType { get; set; }
        public int Version { get; set; }
        public string DateTimeCreated { get; set; }
        public string Status { get; set; }
    }

获取数据:

    public partial class ObjectEntityData
    {
        static List<ObjectEntity> objectEntityList;
        static ObjectEntityOperations objectEntityOps;
        static ObjectEntityData()
        {
            var foundEntities = objectEntityOps.GetAllObjectEntities();

            foreach (var graphNode in foundEntities)
            {
                var entityInformation = new ObjectEntity()
                {
                     Id = graphNode.Data.Id,
                     Name = graphNode.Data.Name,
                     DateTimeCreated = graphNode.Data.DateTimeCreated,
                     Version = graphNode.Data.Version,
                     Status = graphNode.Data.Status,
                     EntityType = graphNode.Data.EntityType
                };

                objectEntityList.Add(entityInformation);
            }
        }

        public IQueryable<ObjectEntity> Items
        {
            get { return objectEntityList.AsQueryable<ObjectEntity>(); }
        }
    }

服务类

public class ObjectEntitiesService : DataService<ObjectEntityData>
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("Items", EntitySetRights.AllRead);

            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
        }
    }

0 个答案:

没有答案