public static bool IsMemberASerializableColumn(this RunTimeAttributeMap member) { if (member.ShouldMemberBeIgnored()) { return(false); } var attr1 = member.GetCustomAttribute <SqlColumnAttribute>(); if (attr1?.SerializableType == null) { return(false); } switch (attr1.SerializableType) { case SerializableType.None: return(false); case SerializableType.Xml: return(true); case SerializableType.Json: return(true); case SerializableType.Csv: return(true); default: throw new ArgumentOutOfRangeException(); } }
public static bool IsMemberAnIdentityColumn(this RunTimeAttributeMap member) { if (member.ShouldMemberBeIgnored()) { return(false); } var sqlColumnAttribute = member.GetCustomAttribute <SqlColumnAttribute>(); var dataAnnotationAttribute = member.GetCustomAttribute <DatabaseGeneratedAttribute>(); return ((dataAnnotationAttribute?.DatabaseGeneratedOption == DatabaseGeneratedOption.Identity || dataAnnotationAttribute?.DatabaseGeneratedOption == DatabaseGeneratedOption.Computed) || (sqlColumnAttribute?.IsIdentityKey == true) ); }
public static string GetNameFromCustomAttributeOrDefault(this RunTimeAttributeMap member) { var attr1 = member.GetCustomAttribute <SqlColumnAttribute>(); var attr2 = member.GetCustomAttribute <ColumnAttribute>(); if (!string.IsNullOrEmpty(attr1?.MapTo)) { return(attr1.MapTo); } if (!string.IsNullOrEmpty(attr2?.Name)) { return(attr2.Name); } return(member.PropertyName); }
public static bool ShouldMemberBeIgnored(this RunTimeAttributeMap member) { var attr1 = member.GetCustomAttribute <SqlColumnAttribute>(); if (attr1?.Ignore == true) { return(true); } var attr2 = member.GetCustomAttribute <NotMappedAttribute>(); if (attr2 != null) { return(true); } return(false); }
public static object GetMemberValue(this RunTimeAttributeMap member, object instanceOfObject, Func <object, string> xmlDeserializer, Func <object, string> jsonDeserializer, Func <object, string> csvDeserializer) { var value = ExtFastMember.GetMemberValue(instanceOfObject, member.PropertyName); var sqlAttribute = member.GetCustomAttribute <SqlColumnAttribute>(); if (sqlAttribute != null && sqlAttribute.SerializableType != SerializableType.None) { switch (sqlAttribute.SerializableType) { case SerializableType.Xml: value = xmlDeserializer.Invoke(value); break; case SerializableType.Json: value = jsonDeserializer.Invoke(value); break; case SerializableType.Csv: value = csvDeserializer.Invoke(value); break; } } return(value); }