Open milad-i opened 1 year ago
I'm sorry to hear that. Do you have some more clues for this mystery, like an error message? Or maybe even.. a stack trace? :)
Sorry for the lack of details. But there isn't any error. stack trace shows nothing when this line runs. Output just displays details before calling Mapster Adapt. and after a while, debugging will be stop without any exceptions or errors.
Actually, I found the reason today. The problem will appear when both the source and destination object has a relationship property.
Product Model :
public virtual Category Category { get; set; }
//--------------------------------------------------
Category Model :
public virtual ICollection<Product> Products { get; set; }
But .ProjectToType
works great in this situation.
When i use Include() in the Lambda expression and try to use Adapt to mapping, the App crashes, and mapping doesn't work.
var product = _context.Products.Include(p => p.Category).FirstOrDefault(p => p.Id == ID).Adapt<ProductViewModel>();