Beispiel #1
0
 private StructureId(ValueType value, Type dataType, StructureIdTypes idType)
 {
     _value = value;
     _hasValue = value != null;
     _dataType = dataType;
     _idType = idType;
 }
        public static IStructureId Create(string value, StructureIdTypes idType)
        {
            var hasValue = !string.IsNullOrWhiteSpace(value);

            switch (idType)
            {
            case StructureIdTypes.Identity:
                return(hasValue
                        ? Create(int.Parse(value))
                        : Create((int?)null));

            case StructureIdTypes.BigIdentity:
                return(hasValue
                        ? Create(long.Parse(value))
                        : Create((long?)null));

            case StructureIdTypes.Guid:
                return(hasValue
                        ? Create(Guid.Parse(value))
                        : Create((Guid?)null));

            case StructureIdTypes.String:
                return(Create(value));
            }

            throw new SisoDbException(ExceptionMessages.StructureId_Create_FromString_WithSpecificId.Inject(value, idType.ToString()));
        }
 private StructureId(ValueType value, Type dataType, StructureIdTypes idType, bool isEmpty)
 {
     _value    = value;
     _isEmpty  = isEmpty;
     _dataType = dataType;
     _idType   = idType;
 }
Beispiel #4
0
 private StructureId(string value, Type dataType)
 {
     _value = value;
     _hasValue = value != null;
     _dataType = dataType;
     _idType = StructureIdTypes.String;
 }
 private StructureId(string value, Type dataType)
 {
     _value    = value;
     _isEmpty  = string.IsNullOrWhiteSpace(value);
     _dataType = dataType;
     _idType   = StructureIdTypes.String;
 }
		private string GetSqlTemplateNameSuffix(StructureIdTypes idType)
		{
			if(idType == StructureIdTypes.String)
				return "String";

			if (idType == StructureIdTypes.Guid)
				return "Guid";

			if (idType.IsIdentity())
				return "Identity";

			throw new SisoDbException(ExceptionMessages.SqlDbIndexesSchemaBuilder_GenerateSql.Inject(idType));
		}
        internal static SqlParameter CreateIdsTableParam(StructureIdTypes idType, IEnumerable<IStructureId> ids)
        {
            if (idType == StructureIdTypes.String)
                return CreateStringIdsTableParam(ids.Select(id => (string)id.Value));

            if(idType == StructureIdTypes.Guid)
                return CreateGuidIdsTableParam(ids.Select(id => (Guid)id.Value));

            if(idType == StructureIdTypes.Identity)
                return CreateIdentityIdsTableParam(ids.Select(id => (int)id.Value));

            if(idType == StructureIdTypes.BigIdentity)
                return CreateBigIdentityIdsTableParam(ids.Select(id => (long)id.Value));

            throw new SisoDbException(Sql2008Exceptions.SqlIdsTableParam_CreateIdsTableParam.Inject(idType));
        }
        public static SqlParameter CreateIdsTableParam(StructureIdTypes idType, IEnumerable<IStructureId> ids)
        {
            if (idType == StructureIdTypes.String)
                return CreateStringIdsTableParam(ids.Select(id => (string)id.Value));

            if(idType == StructureIdTypes.Guid)
                return CreateGuidIdsTableParam(ids.Select(id => (Guid)id.Value));

            if(idType == StructureIdTypes.Identity)
                return CreateIdentityIdsTableParam(ids.Select(id => (int)id.Value));

            if(idType == StructureIdTypes.BigIdentity)
                return CreateBigIdentityIdsTableParam(ids.Select(id => (long)id.Value));

			throw new SisoDbException("Can not create Id-Table parameter for IdType: '{0}'.".Inject(idType));
        }
        public IdAccessor(IStructureProperty property)
            : base(property)
        {
            if (!property.IsRootMember)
            {
                throw new SisoDbException(ExceptionMessages.IdAccessor_InvalidLevel);
            }

            if (!StructureId.IsValidDataType(property.DataType))
            {
                throw new SisoDbException(ExceptionMessages.IdAccessor_UnsupportedPropertyType.Inject(Property.DataType.Name));
            }

            IdType = StructureId.GetIdTypeFrom(property.DataType);

            _getter = StructureIdGetters.For(IdType, Property.DataType);
            _setter = StructureIdSetters.For(IdType, Property.DataType);
        }
        private string GetSqlTemplateNameSuffix(StructureIdTypes idType)
        {
            if (idType == StructureIdTypes.String)
            {
                return("String");
            }

            if (idType == StructureIdTypes.Guid)
            {
                return("Guid");
            }

            if (idType.IsIdentity())
            {
                return("Identity");
            }

            throw new SisoDbException(ExceptionMessages.SqlDbIndexesSchemaBuilder_GenerateSql.Inject(idType));
        }
Beispiel #11
0
        internal static ISetter For(StructureIdTypes structureIdType, Type type)
        {
            switch (structureIdType)
            {
            case StructureIdTypes.String:
                return(new StringSetter());

            case StructureIdTypes.Guid:
                return(type.IsNullableGuidType() ? (ISetter) new NullableGuidSetter() : new GuidSetter());

            case StructureIdTypes.Identity:
                return(type.IsNullableIntType() ? (ISetter) new NullableIntSetter() : new IntSetter());

            case StructureIdTypes.BigIdentity:
                return(type.IsNullableLongType() ? (ISetter) new NullableLongSetter() : new LongSetter());

            default:
                throw new SisoDbException(ExceptionMessages.Setter_Unsupported_type.Inject(structureIdType));
            }
        }
Beispiel #12
0
        public static SqlParameter CreateIdsTableParam(StructureIdTypes idType, IEnumerable <IStructureId> ids)
        {
            if (idType == StructureIdTypes.String)
            {
                return(CreateStringIdsTableParam(ids.Select(id => (string)id.Value)));
            }

            if (idType == StructureIdTypes.Guid)
            {
                return(CreateGuidIdsTableParam(ids.Select(id => (Guid)id.Value)));
            }

            if (idType == StructureIdTypes.Identity)
            {
                return(CreateIdentityIdsTableParam(ids.Select(id => (int)id.Value)));
            }

            if (idType == StructureIdTypes.BigIdentity)
            {
                return(CreateBigIdentityIdsTableParam(ids.Select(id => (long)id.Value)));
            }

            throw new SisoDbException("Can not create Id-Table parameter for IdType: '{0}'.".Inject(idType));
        }
        public static IStructureId Create(object value, StructureIdTypes idType)
        {
            if (value is string)
            {
                return(Create(value as string, idType));
            }

            var hasValue = value != null;

            switch (idType)
            {
            case StructureIdTypes.Identity:
                return(hasValue
                        ? Create((int)value)
                        : Create((int?)null));

            case StructureIdTypes.BigIdentity:
                return(hasValue
                        ? Create((long)value)
                        : Create((long?)null));

            case StructureIdTypes.Guid:
                return(hasValue
                        ? Create((Guid)value)
                        : Create((Guid?)null));

            case StructureIdTypes.String:
                return(hasValue
                        ? Create(value.ToString())
                        : Create(null as string));
            }

            throw new SisoDbException(ExceptionMessages.StructureId_CreateByIdType.Inject(
                                          hasValue ? value.GetType().Name : "null",
                                          idType));
        }
 public static bool IsIdentity(this StructureIdTypes structureIdType)
 {
     return(structureIdType == StructureIdTypes.Identity || structureIdType == StructureIdTypes.BigIdentity);
 }
 public static bool IsString(this StructureIdTypes structureIdType)
 {
     return(structureIdType == StructureIdTypes.String);
 }
 public static bool IsGuid(this StructureIdTypes structureIdType)
 {
     return(structureIdType == StructureIdTypes.Guid);
 }
        public static IStructureId Create(string value, StructureIdTypes idType)
        {
            var hasValue = !string.IsNullOrWhiteSpace(value);

            switch (idType)
            {
                case StructureIdTypes.Identity:
                    return hasValue
                        ? Create(int.Parse(value))
                        : Create((int?)null);
                case StructureIdTypes.BigIdentity:
                    return hasValue
                        ? Create(long.Parse(value))
                        : Create((long?)null);
                case StructureIdTypes.Guid:
                    return hasValue
                        ? Create(Guid.Parse(value))
                        : Create((Guid?)null);
                case StructureIdTypes.String:
                    return Create(value);
            }

            throw new SisoDbException(ExceptionMessages.StructureId_Create_FromString_WithSpecificId.Inject(value, idType.ToString()));
        }
 private StructureId(string value, Type dataType)
 {
     _value = value;
     _isEmpty = string.IsNullOrWhiteSpace(value);
     _dataType = dataType;
     _idType = StructureIdTypes.String;
 }
        public static IStructureId Create(object value, StructureIdTypes idType)
        {
            if (value is string)
                return Create(value as string, idType);

            var hasValue = value != null;

            switch (idType)
            {
                case StructureIdTypes.Identity:
                    return hasValue
                        ? Create((int)value)
                        : Create((int?)null);
                case StructureIdTypes.BigIdentity:
                    return hasValue
                        ? Create((long)value)
                        : Create((long?)null);
                case StructureIdTypes.Guid:
                    return hasValue
                        ? Create((Guid)value)
                        : Create((Guid?)null);
                case StructureIdTypes.String:
                    return hasValue
                        ? Create(value.ToString())
                        : Create(null as string);
            }

            throw new SisoDbException(ExceptionMessages.StructureId_CreateByIdType.Inject(
                hasValue ? value.GetType().Name : "null", 
                idType));
        }
 private StructureId(ValueType value, Type dataType, StructureIdTypes idType, bool isEmpty)
 {
     _value = value;
     _isEmpty = isEmpty;
     _dataType = dataType;
     _idType = idType;
 }