0

I have the following class:

public class Movie
{
    public int MovieId { get; set; }
    public string Title { get; set; }
}

I want to create a lambda expression like this, which contained all properties of the class:

m => new { m.MovieId, m.Title }

Is it possible to generate that dynamically? Thanks

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Eric C.
  • 1
  • 1
  • 2
    I suspect you're trying to do something similar to this: https://stackoverflow.com/questions/606104/how-to-create-linq-expression-tree-to-select-an-anonymous-type – HasaniH May 06 '22 at 15:47
  • 3
    What are you actually trying to accomplish? Why do you need to generate an anonymous type by copying the properties of a concrete type? I suspect you're trying to solve a problem in the wrong way. – D Stanley May 06 '22 at 17:45

0 Answers0