Beispiel #1
0
        public static int?MaxStringLength(MemberInfo info)
        {
            var attribute = ORMUtilitiesHelperFactory.Create().GetAttribute <MaxLengthAttribute>(info);

            if (attribute != null)
            {
                return(attribute.Value);
            }
            return(null);
        }
Beispiel #2
0
        public static string Collation(MemberInfo info)
        {
            var attribute = ORMUtilitiesHelperFactory.Create().GetAttribute <CollationAttribute>(info);

            if (attribute != null)
            {
                return(attribute.Value);
            }
            else
            {
                return(string.Empty);
            }
        }
Beispiel #3
0
        public static long GetPrimaryKey(object target, TableMappingConfiguration configuration)
        {
            var properties = configuration.PropertyCollector.Collect(target.GetType());
            var fields     = configuration.FieldCollector.Collect(target.GetType());

            List <MemberInfo> infoList = new List <MemberInfo>();

            infoList.AddRange(properties);
            infoList.AddRange(fields);

            MemberInfo primaryKeyInfo = infoList.FirstOrDefault(info => ORMUtilitiesHelperFactory.Create().GetAttribute <PrimaryKeyAttribute>(info) != null);

            if (primaryKeyInfo == null)
            {
                throw new InvalidOperationException("Parent type of list must have a primary key.");
            }

            var result = ORMUtilities.GetValueFromMember(primaryKeyInfo, target);

            return(Convert.ToInt64(result));
        }
Beispiel #4
0
 public static bool IsPrimaryKey(MemberInfo info)
 {
     return(ORMUtilitiesHelperFactory.Create().GetAttribute <PrimaryKeyAttribute>(info) != null);
 }
Beispiel #5
0
 public static bool IsMarkedNotNull(MemberInfo info)
 {
     return(ORMUtilitiesHelperFactory.Create().GetAttribute <NotNullAttribute>(info) != null);
 }
Beispiel #6
0
 public static bool IsAutoInc(MemberInfo info)
 {
     return(ORMUtilitiesHelperFactory.Create().GetAttribute <AutoIncrementAttribute>(info) != null);
 }