public MapRelationBase(
			Type         slave,
			MapIndex     slaveIndex,
			MapIndex     masterIndex,
			string       containerName)
		{
			if (slave == null)
				throw new ArgumentNullException("slave");

			if (masterIndex.Fields.Length == 0)
				throw new MappingException("Master index length can not be 0.");

			if ( slaveIndex.Fields.Length == 0)
				throw new MappingException("Slave index length can not be 0.");

			if (masterIndex.Fields.Length != slaveIndex.Fields.Length)
				throw new MappingException("Master and slave indexes do not match.");

			if (string.IsNullOrEmpty(containerName))
				throw new MappingException("Master container field name is wrong.");
			
			_slave           = slave;
			_masterIndex     = masterIndex;
			_slaveIndex      = slaveIndex;
			_containerName   = containerName;
		}
Exemple #2
0
 public static Dictionary <CompoundValue, T> DictionaryToDictionary <T>(
     IDictionary sourceDictionary,
     MapIndex index,
     params object[] parameters)
 {
     return(_defaultSchema.MapDictionaryToDictionary <T>(sourceDictionary, index, parameters));
 }
Exemple #3
0
 public static Dictionary <CompoundValue, T> DataTableToDictionary <T>(
     DataTable sourceTable,
     MapIndex index,
     params object[] parameters)
 {
     return(_defaultSchema.MapDataTableToDictionary <T>(sourceTable, index, parameters));
 }
Exemple #4
0
 public static Dictionary <CompoundValue, T> DataReaderToDictionary <T>(
     IDataReader dataReader,
     MapIndex index,
     params object[] parameters)
 {
     return(_defaultSchema.MapDataReaderToDictionary <T>(dataReader, index, parameters));
 }
Exemple #5
0
 public static Dictionary <CompoundValue, T> ListToDictionary <T>(
     ICollection sourceList,
     MapIndex index,
     params object[] parameters)
 {
     return(_defaultSchema.MapListToDictionary <T>(sourceList, index, parameters));
 }
Exemple #6
0
 public static IDictionary DictionaryToDictionary(
     IDictionary sourceDictionary,
     MapIndex index,
     Type destObjectType,
     params object[] parameters)
 {
     return(_defaultSchema.MapDictionaryToDictionary(sourceDictionary, index, destObjectType, parameters));
 }
Exemple #7
0
 public static IDictionary DataReaderToDictionary(
     IDataReader dataReader,
     MapIndex index,
     Type destObjectType,
     params object[] parameters)
 {
     return(_defaultSchema.MapDataReaderToDictionary(dataReader, index, destObjectType, parameters));
 }
Exemple #8
0
 public static IDictionary ListToDictionary(
     ICollection sourceList,
     MapIndex index,
     Type destObjectType,
     params object[] parameters)
 {
     return(_defaultSchema.MapListToDictionary(sourceList, index, destObjectType, parameters));
 }
Exemple #9
0
 public static Hashtable DataTableToDictionary(
     DataTable sourceTable,
     MapIndex index,
     Type destObjectType,
     params object[] parameters)
 {
     return(_defaultSchema.MapDataTableToDictionary(sourceTable, index, destObjectType, parameters));
 }
Exemple #10
0
 public MapRelation(
     MapResultSet slaveResultSet,
     MapIndex slaveIndex,
     MapIndex masterIndex,
     string containerName)
     : base(slaveResultSet.ObjectType, slaveIndex, masterIndex, containerName)
 {
     _slaveResultSet = slaveResultSet;
 }
Exemple #11
0
		public MapRelation(
			MapResultSet slaveResultSet,
			MapIndex     slaveIndex,
			MapIndex     masterIndex,
			string       containerName)
			: base(slaveResultSet.ObjectType, slaveIndex, masterIndex, containerName)
		{
			_slaveResultSet  = slaveResultSet;
		}
Exemple #12
0
		public void AddRelation(
			MapResultSet slaveResultSet,
			MapIndex     slaveIndex,
			MapIndex     masterIndex,
			string       containerName)
		{
			if (_relationList == null)
				_relationList = new List<MapRelation>();

			_relationList.Add(new MapRelation(slaveResultSet, slaveIndex, masterIndex, containerName));
		}
Exemple #13
0
 public MapNextResult(
     Type type,
     MapIndex slaveIndex,
     MapIndex masterIndex,
     string containerName,
     params MapNextResult[] nextResults)
 {
     _objectType    = type;
     _slaveIndex    = slaveIndex;
     _masterIndex   = masterIndex;
     _containerName = containerName;
     _nextResults   = nextResults;
 }
Exemple #14
0
        public void AddRelation(
            MapResultSet slaveResultSet,
            MapIndex slaveIndex,
            MapIndex masterIndex,
            string containerName)
        {
            if (_relationList == null)
            {
                _relationList = new List <MapRelation>();
            }

            _relationList.Add(new MapRelation(slaveResultSet, slaveIndex, masterIndex, containerName));
        }
		public MapNextResult(
			Type     type,
			MapIndex slaveIndex,
			MapIndex masterIndex,
			string   containerName,
			params MapNextResult[] nextResults)
		{
			_objectType    = type;
			_slaveIndex    = slaveIndex;
			_masterIndex   = masterIndex;
			_containerName = containerName;
			_nextResults   = nextResults;
		}
		public DictionaryIndexListMapper(
			IDictionary  dic,
			MapIndex     index,
			ObjectMapper objectMapper)
		{
			_dic    = dic;
			_mapper = objectMapper;

			_fields = new NameOrIndexParameter[index.Fields.Length];
			_fromSource = new bool[index.Fields.Length];

			for (int i = 0; i < _fields.Length; i++)
			{
				bool fromSource = index.Fields[i].ByName && index.Fields[i].Name[0] == '@';

				_fields[i]     = fromSource? index.Fields[i].Name.Substring(1): index.Fields[i];
				_fromSource[i] = fromSource;
				_isFromSource  = _isFromSource ||  fromSource;
				_isFromDest    = _isFromDest   || !fromSource;
			}
		}
        public DictionaryIndexListMapper(
            IDictionary dic,
            MapIndex index,
            ObjectMapper objectMapper)
        {
            _dic    = dic;
            _mapper = objectMapper;

            _fields     = new NameOrIndexParameter[index.Fields.Length];
            _fromSource = new bool[index.Fields.Length];

            for (int i = 0; i < _fields.Length; i++)
            {
                bool fromSource = index.Fields[i].ByName && index.Fields[i].Name[0] == '@';

                _fields[i]     = fromSource? index.Fields[i].Name.Substring(1): index.Fields[i];
                _fromSource[i] = fromSource;
                _isFromSource  = _isFromSource || fromSource;
                _isFromDest    = _isFromDest || !fromSource;
            }
        }
        public MapRelationBase(
            Type slave,
            MapIndex slaveIndex,
            MapIndex masterIndex,
            string containerName)
        {
            if (slave == null)
            {
                throw new ArgumentNullException("slave");
            }

            if (masterIndex.Fields.Length == 0)
            {
                throw new MappingException("Master index length can not be 0.");
            }

            if (slaveIndex.Fields.Length == 0)
            {
                throw new MappingException("Slave index length can not be 0.");
            }

            if (masterIndex.Fields.Length != slaveIndex.Fields.Length)
            {
                throw new MappingException("Master and slave indexes do not match.");
            }

            if (string.IsNullOrEmpty(containerName))
            {
                throw new MappingException("Master container field name is wrong.");
            }

            _slave         = slave;
            _masterIndex   = masterIndex;
            _slaveIndex    = slaveIndex;
            _containerName = containerName;
        }
Exemple #19
0
        public Hashtable GetIndex(MappingSchema ms, MapIndex masterIndex)
        {
            string    indexId   = masterIndex.ID;
            Hashtable indexHash = null;

            if (_indexies.TryGetValue(indexId, out indexHash))
            {
                return(indexHash);
            }

            ObjectMapper    masterMapper = ms.GetObjectMapper(ObjectType);
            List <MapIndex> createIndex  = new List <MapIndex>();

            indexHash = new Hashtable();

            foreach (object o in List)
            {
                object key = masterIndex.GetValueOrIndex(masterMapper, o);

                if (ms.IsNull(key))
                {
                    continue;
                }

                ArrayList matches = (ArrayList)indexHash[key];

                if (matches == null)
                {
                    indexHash[key] = matches = new ArrayList();
                }

                matches.Add(o);
            }

            return(indexHash);
        }
Exemple #20
0
        public IDictionary <object, IList> GetIndex(MappingSchema ms, MapIndex masterIndex)
        {
            var indexId = masterIndex.ID;

            IDictionary <object, IList> indexHash;

            if (_indexies.TryGetValue(indexId, out indexHash))
            {
                return(indexHash);
            }

            var masterMapper = ms.GetObjectMapper(ObjectType);

            indexHash = new Dictionary <object, IList>();

            foreach (var o in List)
            {
                var key = masterIndex.GetValueOrIndex(masterMapper, o);

                if (ms.IsNull(key))
                {
                    continue;
                }

                IList matches;

                if (!indexHash.TryGetValue(key, out matches))
                {
                    indexHash.Add(key, matches = new List <object>());
                }

                matches.Add(o);
            }

            return(indexHash);
        }
Exemple #21
0
		public  IDictionary<object,IList> GetIndex(MappingSchema ms, MapIndex masterIndex)
		{
			var indexId = masterIndex.ID;

			IDictionary<object,IList> indexHash;

			if (_indexies.TryGetValue(indexId, out indexHash))
				return indexHash;

			var masterMapper = ms.GetObjectMapper(ObjectType);

			indexHash = new Dictionary<object, IList>();

			foreach (var o in List)
			{
				var key = masterIndex.GetValueOrIndex(masterMapper, o);

				if (ms.IsNull(key))
					continue;

				IList matches;

				if (!indexHash.TryGetValue(key, out matches))
					indexHash.Add(key, matches = new List<object>());

				matches.Add(o);
			}

			return indexHash;
		}