.Include does work with the Get<TEntity>
Hi pals,
When doing the following query, the NameEntityType is still null:
public class NameEntity {
public int Id { get; set; }
public int NameEntityTypeId { get; set; }
public virtual NameEntityType NameEntityType { get; set; }
}
public class NameEntityType {
public int Id { get; set; }
public virtual System.Collections.Generic.ICollection<NameEntity> NameEntities { get; set; }
}
var res = queryFactory.Query("NameEntity")
.Include("NameEntityType", queryFactory.Query("NameEntityType"), "NameEntityTypeId")
.Get<NameEntity>();
Could you please let me know about the way to solve the issue?
@brezaie currently the Include works only with Get<dynamic> overload, this is a known limitation, that will get solved soon.
You can for now return the result as IEnumeratble<dynamic> then cast it to the type you want IEnumerable<T>.
@ahmad-moussawi Do you have an example how to cast the IEnumerable<dynamic> (which I think is Dictionary<string, object> at runtime) to IEnumerable<T>? The explicit casting or using Cast() from the generic collection will throw InvalidCastException, I also tried Slapper.AutoMapper but it seems like it does not support mapping with private constructors/setters.
@ahmad-moussawi Has the work been done to allow for the Include to work with the generic type methods?