public void WriteObject(IDataReader <string> dataReader) { var token = dataReader.ReferenceToken; if (token != null) { References.TryAdd(token, CurrentReference); } }
/// <summary> /// Gets the required non collection references for a type. /// </summary> /// <param name="entityType">The type of the entity to get the references from</param> /// <returns>A list of info on the types</returns> public static IEnumerable <TypeInfo> GetRequiredReferences(Type entityType) { if (ReferenceCache.TryGetValue(entityType, out var types)) { return(types); } var referenceTypes = entityType.GetProperties() .Where(p => p.GetCustomAttributes <EntityForeignKey>().Any(a => a.Required) && p.PropertyType.IsAssignableTo <IAbstractModel>()) .Select(p => new TypeInfo { Name = p.Name, Type = p.PropertyType }) .ToList(); ReferenceCache.TryAdd(entityType, referenceTypes); return(referenceTypes); }