6

Is it possible to map a complex class with both a nested class and a collection class with NPoco? I've had a look at the documentation but it's not 100% clear whether i can map to this class with one query.

For example given these classes:

public class User
{
  public int UserId { get; set; }
  public string Name { get; set; }
  public Address Address { get; set; }
  public List<Car> Cars { get; set; }
}

public class Address
{
  public string Street { get; set; }
  public string City { get; set; }
}

public class Car
{
  public string Make { get; set; }
  public string Color { get; set; }
}

Would it be possible to map the User and populate the Address property and the Cars property with one query?

I've seen i can do a OneToMany Fetch, and that it's also possible to map a property which is a class, but i'm not certain if i can map a class with both of these with one fetch.

1 Answer 1

0

Its not really possible. I would map to a flattened DTO first then perform a LINQ query to get it into your above model.

1

Not the answer you're looking for? Browse other questions tagged or ask your own question.