0

我正在尝试从我的 WCF 数据服务返回实体列表。我没有使用实体框架,而是从 Neo4j 中提取数据并返回那些 asQueryeable 。如果我运行代码说找不到 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;
        }
    }
4

0 回答 0