Add methods to a model using entity framework

前端 未结 4 756
暖寄归人
暖寄归人 2021-02-13 01:52

With entity framework, is it possible to add methods to an object class ? For example, i have a CLIENT mapping and i would like to create a \"getAgeFromBirhDate\" method.

4条回答
  •  野的像风
    2021-02-13 02:04

    An example for first answer:

    if you have an entity named Flower you can use this partial class for adding method to it:

    namespace Garden //same as namespace of your entity object
    {
        public partial class Flower  
        {
            public static Flower Get(int id)
            { 
                //
            }
        }
    }
    

提交回复
热议问题