koenbeuk / EntityFrameworkCore.Projectables

Project over properties and functions in your linq queries
MIT License
297 stars 20 forks source link

UseMemberBody to use the body of another member #28

Closed bocca closed 2 years ago

bocca commented 2 years ago

This change resolves #25, supporting two diffent approaches.

        public record Entity
        {
            public int Id { get; set; }

            [Projectable(UseMemberBody = nameof(Computed2))]
            public int Computed1 => Id;

            private int Computed2 => Id * 2;

            [Projectable(UseMemberBody = nameof(Computed4))]
            public int Computed3 => Id;

            private static Expression<Func<Entity, int>> Computed4 => x => x.Id * 3;
        }

Code written for properties and methods, although I have only tested for properties. Xunit tests included.

This change also adds the member full path to the error message for #26. It can be improved further, though.

koenbeuk commented 2 years ago

Thanks for the contribution!