Code: Select all
public virtual async Task<TEntity> GetByIdAsync(object[] keyValues,
List<Expression<Func<TEntity, object>>> includes,
CancellationToken cancellationToken = default(CancellationToken))
{
Task<TEntity> model = null;
foreach (var include in includes)
{
if (include.Body.Type.GetInterface(nameof(IEnumerable<TEntity>)) != null)
{ //this part generates SQL Below
await DbSet.Include(include).LoadAsync(cancellationToken);
model = DbSet.FindAsync(keyValues, cancellationToken);
}
else //this part is working
{
var propertyName = ((MemberExpression)include.Body).Member.Name;
model = DbSet.FindAsync(keyValues, cancellationToken);
await DbContext.Entry(model.Result).Navigation(propertyName).LoadAsync(cancellationToken);
}
}
if (model == null)
model = DbSet.FindAsync(keyValues, cancellationToken);
return await model;
}
Code: Select all
SELECT "product.MhpProducts".MP_MHP_ID, "product.MhpProducts".MP_PRODUCT_ID, "product.MhpProducts".MP_G_ORDER, "product.MhpProducts".G_END_DATE, "product.MhpProducts".G_INSERT_BY, "product.MhpProducts".G_INSERT_DATE, "product.MhpProducts".G_IS_DELETED, "product.MhpProducts".G_START_DATE, "product.MhpProducts"."MP_WEST_CORE._DOMAIN._ENTITIES._WEST_LIFE._MHP_PRODUCT" FROM MHP_PRODUCT "product.MhpProducts" INNER JOIN ( SELECT "product0".TP_ID FROM TREE_PRODUCT "product0" ) "t" ON "product.MhpProducts".MP_PRODUCT_ID = "t".TP_ID ORDER BY "t".TP_ID
it seems like a Bug