C# – OData:无法使用带有’new’属性的Type构建System.Web.Http.OData.Delta
我在ASP.NET Web API 2(而不是Core)中运行一个项目,我有一个像这样的对象:
public class Desktop : EntityData { public Desktop() { } public new Guid Id { get { return Guid.Parse(base.Id); } set { base.Id = value.ToString(); } } ... } public abstract class EntityData { protected EntityData(); public string Id { get; set; } public bool Deleted { get; set; } }
可以看出,有一个带有new
运算符的属性Id
。
这阻碍了我使用任何现有的构造函数创建一个新的Delta
对象:
Delta delta = new Delta(); Delta delta = new Delta(typeof(Desktop)); Delta delta = new Delta(typeof(Desktop), new string[] { "Id" });
实际上构造函数抛出exception,说
已添加具有相同键的项目。
如何成功构建Delta
对象?
非常感谢你!
cghersi
- WebAPI令牌颁发授权
- 在Owin启动期间,Simple Injector无法为每个Web API请求注册类注入
- HttpClient调用Windows-Authenication ApiController方法…但没有WindowsIdentity出现
- Web Api 2会话
- Web Api控制器无法识别Json方法
- 任何人都可以使用示例客户端应用程序解释IExceptionHandler的工作流程
- 将HttpRequestMessage转换为OwinRequest和OwinResponse转换为HttpResponseMessage
- ASP.NET Web API序列化JSON错误:“自我引用循环”
- 使用媒体类型对ASP.NET Web API 2进行版本控制