private FieldInfo SearchOidSupportableField(Type type) { var fields = _reflectionService.GetFields(type); return((from fieldInfo in fields let attributes = fieldInfo.GetCustomAttributes(true) let hasAttribute = attributes.OfType <OIDAttribute>().Any() let isOidSupportedType = fieldInfo.FieldType == typeof(OID) || fieldInfo.FieldType == typeof(long) where hasAttribute && isOidSupportedType select fieldInfo).FirstOrDefault()); }
private void CascadeDelete <T>(T plainObject) { var fields = _reflectionService.GetFields(plainObject.GetType()); fields = (from fieldInfo in fields let attributes = fieldInfo.GetCustomAttributes(true) where attributes.OfType <CascadeDeleteAttribute>().Any() select fieldInfo).ToList(); foreach (var fieldInfo in fields) { Delete(fieldInfo.GetValue(plainObject)); } }