How to create a computed property in Data Services (OData)?

前端 未结 2 1325
猫巷女王i
猫巷女王i 2020-12-17 00:33

I am creating an OData service with WCF Data Services using an EDMX. How can I create a computed property for an entity type, so that its value gets computed in the service

2条回答
  •  再見小時候
    2020-12-17 00:48

    The solution I found is to use Entity Framework Code First instead of an EDMX. It allows you to create computed properties just by creating standard properties in code.
    Here is an example:

    public class Person
    {
      public String FirstName { get; set; }
      public String LastName { get; set; }
      public String FullName
      {
        get { return FirstName + " " + LastName; }
      }
    }
    

提交回复
热议问题