/// <summary> /// Includes the properties. /// </summary> /// <param name="entity">The entity.</param> /// <param name="includes">The includes.</param> protected void includeProperties(object entity, string includes) { if (string.IsNullOrEmpty(includes)) { return; } foreach (var str in includes.Split(',')) { var entry = Context.Entry(entity); var pieces = str.Split(new[] { '.' }, 2); var navig = entry.Navigation(pieces[0]); navig.Load(); if (pieces.Length == 2) { var newEnt = navig.CurrentValue; if (newEnt.GetType().GetInterfaces().Contains(typeof(IEnumerable))) { var collec = (IEnumerable)newEnt; foreach (var ent in collec) { includeProperties(ent, pieces[1]); } } else { includeProperties(newEnt, pieces[1]); } } } }