/// <summary> /// Gets the bulk runtime type handle metadata. /// </summary> /// <param name="type">The type.</param> /// <param name="outputIdentity">The output identity.</param> /// <returns></returns> private static BulkRuntimeTypeHandleMetadata GetBulkRuntimeTypeHandleMetadata(Type type, bool?outputIdentity = null) { if (BulkOperationsCache.TryGetValue(type.TypeHandle, out var bulkRuntimeTypeHandleMetadata)) { return(bulkRuntimeTypeHandleMetadata); } bulkRuntimeTypeHandleMetadata = new BulkRuntimeTypeHandleMetadata(); var tableName = Resolvers.Table(type); var keyProperty = Resolvers.KeyProperty(type, out var isIdentity); var columns = new List <Tuple <string, Type> >(); var propertyInfos = new List <PropertyInfo>(); foreach (var typeProperty in Resolvers.Properties(type)) { if (typeProperty == keyProperty) { if (isIdentity) { bulkRuntimeTypeHandleMetadata.IdentityColumn = Resolvers.DataColumn(typeProperty); } } if (typeProperty.PropertyInfo.GetSetMethod() != null) { columns.Add(Resolvers.DataColumn(typeProperty)); propertyInfos.Add(typeProperty.PropertyInfo); } } if (outputIdentity.HasValue && outputIdentity.Value) { columns.Add(new Tuple <string, Type>("InternalId", typeof(int))); propertyInfos.Add(null); } bulkRuntimeTypeHandleMetadata.Columns = columns.ToArray(); bulkRuntimeTypeHandleMetadata.PropertyInfos = propertyInfos.ToArray(); bulkRuntimeTypeHandleMetadata.Name = tableName; BulkOperationsCache.TryAdd(type.TypeHandle, bulkRuntimeTypeHandleMetadata); return(bulkRuntimeTypeHandleMetadata); }