I am using this Expression to create my ViewModel from Database Models:
ViewModel.cs:
public class TestViewModel
{
public static Expression<Func<TestModel, TestViewModel>> Projection => dbModel => new TestViewModel
{
Name = dbModel.Name,
PropertiesCommaSeparated = string.Join(", ", dbModel.TestProperties.Select(x => x.TestProperty.Value))
};
public string Name { get; set; }
public string PropertiesCommaSeparated { get; set; }
}
Since string.Join("","")
is not supported in Linq to SQL this fails.
According to this answer https://stackoverflow.com/a/934668 I want to use a stored procedure.
Is it possible to execute a stored procedure in an expression like this?
I am using Entity Framework .NET Core 3.1