How to get Web API OData v4 to use DateTime

前端 未结 12 1208
时光取名叫无心
时光取名叫无心 2020-12-02 14:50

I have a fairly large data model that I want to expose using Web API OData using the OData V4 protocol.

The underlying data is stored in a SQL Server 2012 database.

12条回答
  •  情深已故
    2020-12-02 15:03

    public class Customer
    {
        private DateTimeWrapper dtw;
    
        public int Id { get; set; }
    
        public string Name { get; set; }
    
        public DateTime Birthday
        {
           get { return dtw; }
           set { dtw = value; }
        }
    
        [NotMapped]
        public DateTimeOffset BirthdayOffset
        {
            get { return dtw; }
            set { dtw = value; }
        }
    }
    
    
    var customer = builder.EntityType();
    customer.Ignore(t => t.Birthday);
    customer.Property(t => t.BirthdayOffset).Name = "Birthday";
    

提交回复
热议问题