private string GetReadOnlyMembersOnLoad(SecurityObjectBuilder securityObjectBuilder) { List <string> denyMembers = new List <string>(); IEntityType entityType = model.FindEntityType(securityObjectBuilder.SecurityObject.GetType()); if (!entityType.Equals(null)) { var properties = entityType.GetProperties(); var denyMembersProperty = GetDenyMembers(properties.Select(p => p.Name), entityType.ClrType, securityObjectBuilder.RealObject); var propertiesNavigation = entityType.GetNavigations(); var denyMembersNavigationProperty = GetDenyMembers(propertiesNavigation.Select(p => p.Name), entityType.ClrType, securityObjectBuilder.RealObject); denyMembers.AddRange(denyMembersProperty); denyMembers.AddRange(denyMembersNavigationProperty); } return(string.Join(";", denyMembers)); }
private string[] GetIncludes(Type type, string parentProperty = "", params Type[] parentsType) { List <string> includes = new List <string>(); IEntityType EntityType = _dbContext.Model.FindEntityType(type); parentsType = parentsType.Concat(new Type[] { type }).ToArray(); foreach (var property in EntityType.GetNavigations()) { if (EntityType.Equals(property.ForeignKey.DeclaringEntityType)) { includes.Add(parentProperty + property.Name); if (!parentsType.Contains(property.FieldInfo.FieldType)) { includes.AddRange(GetIncludes(property.FieldInfo.FieldType, parentProperty + property.Name + ".", parentsType)); } } } return(includes.ToArray()); }