Beispiel #1
0
 private Set<ShardId> GetShardIdSet()
 {
     Set<ShardId> hashedSet = new HashedSet<ShardId>();
     hashedSet.Add(new ShardId(1));
     hashedSet.Add(new ShardId(2));
     hashedSet.Add(new ShardId(3));
     return hashedSet;
 }
Beispiel #2
0
 /// <summary>
 /// Create a Schedule, copying values from the given schedule.
 /// </summary>
 ///
 /// <param name="schedule">The Schedule to copy values from.</param>
 public Schedule(Schedule schedule)
 {
     this.whiteIntervalList_ = new HashedSet<RepetitiveInterval>();
     this.blackIntervalList_ = new HashedSet<RepetitiveInterval>();
     // RepetitiveInterval is immutable, so we don't need to make a deep copy.
     ILOG.J2CsMapping.Collections.Collections.AddAll(schedule.whiteIntervalList_,whiteIntervalList_);
     ILOG.J2CsMapping.Collections.Collections.AddAll(schedule.blackIntervalList_,blackIntervalList_);
 }
 public ISet<Instrument> GetAllUniqueInstruments()
 {
     ISet<Instrument> instruments = new HashedSet<Instrument>();
     foreach (Transaction transaction in _transactionList)
     {
         instruments.Add(transaction.Instrument);
     }
     return instruments;
 }
Beispiel #4
0
        /// <summary>
        /// Constructor for creating a new radiology report for the specified procedure.
        /// </summary>
        /// <param name="procedure">The procedure being reported.</param>
        public Report(Procedure procedure)
        {
            _procedures = new HashedSet<Procedure>();
            _parts = new List<ReportPart>();

            _procedures.Add(procedure);
            procedure.Reports.Add(this);

            // create the main report part
            ReportPart mainReport = new ReportPart(this, 0);
            _parts.Add(mainReport);
        }
		public ISet<string> GetQuerySpaces()
		{
			ISet<string> result = new HashedSet<string>();

			foreach (ICriteriaInfoProvider info in criteriaInfoMap.Values)
			{
				result.AddAll(info.Spaces);
			}

			foreach (ICollectionPersister collectionPersister in criteriaCollectionPersisters)
			{
				result.AddAll(collectionPersister.CollectionSpaces);
			}
			return result;
		}
		private void QueryKeyFilterDescLikeToCompare(out QueryKey qk, out QueryKey qk1)
		{
			const string filterName = "DescriptionLike";
			var f = new FilterImpl(sessions.GetFilterDefinition(filterName));
			f.SetParameter("pLike", "so%");
			var fk =  new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco);
			ISet<FilterKey> fks = new HashedSet<FilterKey> { fk };
			qk = new QueryKey(sessions, SqlAll, new QueryParameters(), fks);

			var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName));
			f1.SetParameter("pLike", "%ing");
			var fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco);
			fks = new HashedSet<FilterKey> { fk1 };
			qk1 = new QueryKey(sessions, SqlAll, new QueryParameters(), fks);
		}
		public virtual void OnMerge(MergeEvent @event)
		{
			EventCache copyCache = new EventCache();
			
			OnMerge(@event, copyCache);
			
			// TODO: iteratively get transient entities and retry merge until one of the following conditions:
			//   1) transientCopyCache.size() == 0
			//   2) transientCopyCache.size() is not decreasing and copyCache.size() is not increasing
			
			// TODO: find out if retrying can add entities to copyCache (don't think it can...)
			// For now, just retry once; throw TransientObjectException if there are still any transient entities
			
			IDictionary transientCopyCache = this.GetTransientCopyCache(@event, copyCache);
			
			if (transientCopyCache.Count > 0)
			{
				RetryMergeTransientEntities(@event, transientCopyCache, copyCache);
				
				// find any entities that are still transient after retry
				transientCopyCache = this.GetTransientCopyCache(@event, copyCache);
				
				if (transientCopyCache.Count > 0)
				{
					ISet<string> transientEntityNames = new HashedSet<string>();
					
					foreach (object transientEntity in transientCopyCache.Keys)
					{
						string transientEntityName = @event.Session.GuessEntityName(transientEntity);
						
						transientEntityNames.Add(transientEntityName);
						
						log.InfoFormat(
							"transient instance could not be processed by merge: {0} [{1}]",
							transientEntityName,
							transientEntity.ToString());
					}
					
					throw new TransientObjectException("one or more objects is an unsaved transient instance - save transient instance(s) before merging: " + transientEntityNames);
				}
			}

			copyCache.Clear();
			copyCache = null;
		}
Beispiel #8
0
        public DocumentBuilder(DocumentMapping classMapping, Analyzer defaultAnalyzer, IDirectoryProvider[] directoryProviders,
                               IIndexShardingStrategy shardingStrategy)
        {
            analyzer = new ScopedAnalyzer();
            this.directoryProviders = directoryProviders;
            this.shardingStrategy = shardingStrategy;

            if (classMapping == null) throw new AssertionFailure("Unable to build a DocumemntBuilder with a null class");

            rootClassMapping = classMapping;

            Set<System.Type> processedClasses = new HashedSet<System.Type>();
            processedClasses.Add(classMapping.MappedClass);
            CollectAnalyzers(rootClassMapping, defaultAnalyzer, true, string.Empty, processedClasses);
            //processedClasses.remove( clazz ); for the sake of completness
            analyzer.GlobalAnalyzer = defaultAnalyzer;
            if (idMapping == null)
                throw new SearchException("No document id for: " + classMapping.MappedClass.Name);
        }
		public IList TransformList(IList list)
		{
			IList result = (IList)Activator.CreateInstance(list.GetType());
			ISet<Identity> distinct = new HashedSet<Identity>();

			for (int i = 0; i < list.Count; i++)
			{
				object entity = list[i];
				if (distinct.Add(new Identity(entity)))
				{
					result.Add(entity);
				}
			}

			if (log.IsDebugEnabled)
			{
				log.Debug(string.Format("transformed: {0} rows to: {1} distinct results",
				                        list.Count, result.Count));
			}
			return result;
		}
        public DocumentBuilder(System.Type clazz, Analyzer defaultAnalyzer, IDirectoryProvider[] directoryProviders,
            IIndexShardingStrategy shardingStrategy)
        {
            analyzer = new ScopedAnalyzer();
            beanClass = clazz;
            this.directoryProviders = directoryProviders;
            this.shardingStrategy = shardingStrategy;

            if (clazz == null) throw new AssertionFailure("Unable to build a DocumemntBuilder with a null class");

            rootPropertiesMetadata = new PropertiesMetadata();
            rootPropertiesMetadata.boost = GetBoost(clazz);
            rootPropertiesMetadata.analyzer = defaultAnalyzer;

            Set<System.Type> processedClasses = new HashedSet<System.Type>();
            processedClasses.Add(clazz);
            InitializeMembers(clazz, rootPropertiesMetadata, true, string.Empty, processedClasses);
            //processedClasses.remove( clazz ); for the sake of completness
            analyzer.GlobalAnalyzer = rootPropertiesMetadata.analyzer;
            if (idKeywordName == null)
                throw new SearchException("No document id for: " + clazz.Name);
        }
		public void DefaultModifiableWithReadOnlyQueryForCollectionEntities()
		{
			Container cOrig = CreateContainer();
			ISet<object> expectedInitializedObjects =
					new HashedSet<object>(
						new object[]
						{
							cOrig,
							//cOrig.NoProxyInfo,
							cOrig.ProxyInfo,
							cOrig.NonLazyInfo,
							//cOrig.NoProxyOwner,
							cOrig.ProxyOwner,
							cOrig.NonLazyOwner,
							cOrig.LazyDataPoints.First(),
							cOrig.NonLazyJoinDataPoints.First(),
							cOrig.NonLazySelectDataPoints.First()
						});

			ISet<object> expectedReadOnlyObjects = new HashedSet<object>();
	
			ISession s = OpenSession();
			Assert.That(s.DefaultReadOnly, Is.False);
			ITransaction t = s.BeginTransaction();
			s.Save(cOrig);
			CheckContainer(cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s);
			s.DefaultReadOnly = true;
			Assert.That(s.DefaultReadOnly, Is.True);
			CheckContainer(cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s);
			t.Commit();
			s.Close();
	
			s = OpenSession();
			t = s.BeginTransaction();
			Assert.That(s.DefaultReadOnly, Is.False);
			DataPoint dp = s.CreateQuery("select c.LazyDataPoints from Container c join c.LazyDataPoints where c.Id=" + cOrig.Id)
				.SetReadOnly(true)
				.UniqueResult<DataPoint>();
			Assert.That(s.IsReadOnly(dp), Is.True);
			t.Commit();
			s.Close();
			s = OpenSession();
			t = s.BeginTransaction();
			s.CreateQuery("delete from DataPoint").ExecuteUpdate();
			s.CreateQuery("delete from Container").ExecuteUpdate();
			s.CreateQuery("delete from Info").ExecuteUpdate();
			s.CreateQuery("delete from Owner").ExecuteUpdate();
			t.Commit();
			s.Close();
		}
        private static void InitialiseBuiltIn()
        {
            HashedSet<string> builtin;

            if (_builtin == null)
            {
                lock (_synLock)
                {
                    if (_builtin == null)
                    {
                        builtin = new HashedSet<string>();
                        builtin.Add("NaN");
                        builtin.Add("top");

                        _builtin = builtin;
                    }
                }
            }
        }
        private static void InitialiseReserved()
        {
            if (Reserved == null)
            {
                lock (_synLock)
                {
                    if (Reserved == null)
                    {
                        // See http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Reserved_Words

                        // JavaScript 1.5 reserved words
                        // Words reserved for future use
                        // These are not reserved, but should be taken into account
                        // in isValidIdentifier (See jslint source code)

                        var reserved = new HashedSet<string>
                                           {
                                               "break",
                                               "case",
                                               "catch",
                                               "continue",
                                               "default",
                                               "delete",
                                               "do",
                                               "else",
                                               "finally",
                                               "for",
                                               "function",
                                               "if",
                                               "in",
                                               "instanceof",
                                               "new",
                                               "return",
                                               "switch",
                                               "this",
                                               "throw",
                                               "try",
                                               "typeof",
                                               "var",
                                               "void",
                                               "while",
                                               "with",
                                               "abstract",
                                               "boolean",
                                               "byte",
                                               "char",
                                               "class",
                                               "const",
                                               "debugger",
                                               "double",
                                               "enum",
                                               "export",
                                               "extends",
                                               "final",
                                               "float",
                                               "goto",
                                               "implements",
                                               "import",
                                               "int",
                                               "interface",
                                               "long",
                                               "native",
                                               "package",
                                               "private",
                                               "protected",
                                               "public",
                                               "short",
                                               "static",
                                               "super",
                                               "synchronized",
                                               "throws",
                                               "transient",
                                               "volatile",
                                               "arguments",
                                               "eval",
                                               "true",
                                               "false",
                                               "Infinity",
                                               "NaN",
                                               "null",
                                               "undefined"
                                           };

                        Reserved = reserved;
                    }
                }
            }
        }
 private static void InitialiseBuiltIn()
 {
     if (_builtin == null)
     {
         lock (_synLock)
         {
             if (_builtin == null)
             {
                 var builtin = new HashedSet<string> {"NaN", "top"};
                 _builtin = builtin;
             }
         }
     }
 }
Beispiel #15
0
 private void CheckPropertyDuplication()
 {
     HashedSet<string> names = new HashedSet<string>();
     foreach (Property prop in PropertyIterator)
     {
         if (!names.Add(prop.Name))
             throw new MappingException("Duplicate property mapping of " + prop.Name + " found in " + EntityName);
     }
 }
        private void saveCoures()
        {
            try
            {
                string ProfessionID = context.Request.Form.Get("Profession");
                string FacultyID = context.Request.Form.Get("Faculty");

                DepartmentService ds = new DepartmentService();
                Profession profession = ds.getProfessionByID(ProfessionID);
                Faculty faculty = ds.getFacultyByID(FacultyID);
                if (profession != null && faculty != null)
                {
                    ISet<Coures> couresSet = new HashedSet<Coures>();
                    string[] couresArr = context.Request.Form.GetValues("Coures");
                    CouresService cs = new CouresService();
                    foreach (string c in couresArr) {
                       Coures coures = cs.getCouresByID(c);
                       if (coures != null)
                       couresSet.Add(coures);
                    }

                    ExamPlan p = new ExamPlan();
                    setValue(p, context);
                    p.Profession = profession;
                    p.Faculty = faculty;
                    p.CouresSet = couresSet;
                    PlanService ps = new PlanService();
                    ps.save(p);
                    context.Response.Write("1");
                }
            }
            catch (Exception e)
            {
                context.Response.Write("0");
            }
        }
		/// <summary> 
		/// Given a collection of entity instances that used to
		/// belong to the collection, and a collection of instances
		/// that currently belong, return a collection of orphans
		/// </summary>
		protected static ICollection GetOrphans(ICollection oldElements, ICollection currentElements, string entityName,
		                                        ISessionImplementor session)
		{
			// short-circuit(s)
			if (currentElements.Count == 0)
			{
				// no new elements, the old list contains only Orphans
				return oldElements;
			}
			if (oldElements.Count == 0)
			{
				// no old elements, so no Orphans neither
				return oldElements;
			}

			IType idType = session.Factory.GetEntityPersister(entityName).IdentifierType;

			// create the collection holding the orphans
			List<object> res = new List<object>();

			// collect EntityIdentifier(s) of the *current* elements - add them into a HashSet for fast access
			HashedSet<TypedValue> currentIds = new HashedSet<TypedValue>();
			foreach (object current in currentElements)
			{
				if (current != null && ForeignKeys.IsNotTransient(entityName, current, null, session))
				{
					object currentId = ForeignKeys.GetEntityIdentifierIfNotUnsaved(entityName, current, session);
					currentIds.Add(new TypedValue(idType, currentId, session.EntityMode));
				}
			}

			// iterate over the *old* list
			foreach (object old in oldElements)
			{
				object oldId = ForeignKeys.GetEntityIdentifierIfNotUnsaved(entityName, old, session);
				if (!currentIds.Contains(new TypedValue(idType, oldId, session.EntityMode)))
				{
					res.Add(old);
				}
			}

			return res;
		}
Beispiel #18
0
        public void PostInitialize(ISet<System.Type> indexedClasses)
        {
            // this method does not requires synchronization
            Type plainClass = rootClassMapping.MappedClass;
            ISet<Type> tempMappedSubclasses = new HashedSet<System.Type>();

            // together with the caller this creates a o(2), but I think it's still faster than create the up hierarchy for each class
            foreach (Type currentClass in indexedClasses)
            {
                if (plainClass.IsAssignableFrom(currentClass))
                {
                    tempMappedSubclasses.Add(currentClass);
                }
            }

            mappedSubclasses = tempMappedSubclasses;
        }
Beispiel #19
0
 /// <summary>
 /// Create a Schedule with empty whiteIntervalList and blackIntervalList.
 /// </summary>
 ///
 public Schedule()
 {
     this.whiteIntervalList_ = new HashedSet<RepetitiveInterval>();
     this.blackIntervalList_ = new HashedSet<RepetitiveInterval>();
 }
Beispiel #20
0
        /// <summary>
        /// A helper function to calculate black interval results or white interval
        /// results.
        /// </summary>
        ///
        /// <param name="list"></param>
        /// <param name="timeStamp">The time stamp as milliseconds since Jan 1, 1970 UTC.</param>
        /// <param name="positiveResult">The positive result which is updated.</param>
        /// <param name="negativeResult">The negative result which is updated.</param>
        private static void calculateIntervalResult(
				HashedSet<RepetitiveInterval> list, double timeStamp,
				Interval positiveResult, Interval negativeResult)
        {
            Object[] array = ILOG.J2CsMapping.Collections.Collections.ToArray(list);
            System.Array.Sort(array);
            /* foreach */
            foreach (Object elementObj  in  array) {
                RepetitiveInterval element = (RepetitiveInterval) elementObj;

                RepetitiveInterval.Result result = element.getInterval(timeStamp);
                Interval tempInterval = result.interval;
                if (result.isPositive == true) {
                    try {
                        positiveResult.unionWith(tempInterval);
                    } catch (Interval.Error ex) {
                        // We don't expect to get this error.
                        throw new Exception("Error in Interval.unionWith: "
                                + ex.Message);
                    }
                } else {
                    if (!negativeResult.isValid())
                        negativeResult.set(tempInterval);
                    else
                        negativeResult.intersectWith(tempInterval);
                }
            }
        }
		public Iesi.Collections.Generic.ISet<string> GetQuerySpaces()
		{
			Iesi.Collections.Generic.ISet<string> result = new HashedSet<string>();

			foreach (string entityName in criteriaEntityNames.Values)
			{
				result.AddAll(Factory.GetEntityPersister(entityName).QuerySpaces);
			}

			foreach (ICollectionPersister collectionPersister in criteriaCollectionPersisters)
			{
				result.AddAll(collectionPersister.CollectionSpaces);
			}
			return result;
		}
		public void DefaultModifiableWithFilterCollectionEntities()
		{
			Container cOrig = CreateContainer();
			
			ISet<object> expectedInitializedObjects =
					new HashedSet<object>(
						new object[]
						{
							cOrig,
							//cOrig.NoProxyInfo,
							cOrig.ProxyInfo,
							cOrig.NonLazyInfo,
							//cOrig.NoProxyOwner,
							cOrig.ProxyOwner,
							cOrig.NonLazyOwner,
							cOrig.LazyDataPoints.First(),
							cOrig.NonLazyJoinDataPoints.First(),
							cOrig.NonLazySelectDataPoints.First()
						});

			ISet<object> expectedReadOnlyObjects = new HashedSet<object>();
	
			ISession s = OpenSession();
			Assert.That(s.DefaultReadOnly, Is.False);
			ITransaction t = s.BeginTransaction();
			s.Save(cOrig);
			CheckContainer(cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s);
			s.DefaultReadOnly = true;
			Assert.That(s.DefaultReadOnly, Is.True);
			CheckContainer(cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s);
			t.Commit();
			s.Close();
	
			s = OpenSession();
			t = s.BeginTransaction();
			Assert.That(s.DefaultReadOnly, Is.False);
			Container c = s.Get<Container>(cOrig.Id);
			Assert.That(cOrig, Is.Not.SameAs(c));
			expectedInitializedObjects =
					new HashedSet<object>(
						new object[]
						{
							c, c.NonLazyInfo,
							//c.NoProxyOwner,
							c.ProxyOwner,
							c.NonLazyOwner,
							c.NonLazyJoinDataPoints.First(),
							c.NonLazySelectDataPoints.First()
						});

			expectedReadOnlyObjects = new HashedSet<object>();
			IList list = s.CreateFilter(c.LazyDataPoints, "" ).SetMaxResults(1).List();
			Assert.That(list.Count, Is.EqualTo(1));
			Assert.That(s.IsReadOnly(list[0]), Is.False);
			list = s.CreateFilter(c.NonLazyJoinDataPoints, "").SetMaxResults(1).List();
			Assert.That(list.Count, Is.EqualTo(1));
			Assert.That(s.IsReadOnly(list[0]), Is.False);
			list = s.CreateFilter(c.NonLazySelectDataPoints, "").SetMaxResults(1).List();
			Assert.That(list.Count, Is.EqualTo(1));
			Assert.That(s.IsReadOnly(list[0]), Is.False);
			t.Commit();
			s.Close();
			s = OpenSession();
			t = s.BeginTransaction();
			s.CreateQuery("delete from DataPoint").ExecuteUpdate();
			s.CreateQuery("delete from Container").ExecuteUpdate();
			s.CreateQuery("delete from Info").ExecuteUpdate();
			s.CreateQuery("delete from Owner").ExecuteUpdate();
			t.Commit();
			s.Close();
		}
Beispiel #23
0
		public void SetDefaults()
		{
			DateTime today = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

			StringSet = new HashedSet<string> {"foo", "bar", "baz"};

			StringDateMap = new SortedList();
			StringDateMap.Add("now", DateTime.Now);
			StringDateMap.Add("never", null); // value is persisted since NH-2199
			// according to SQL Server the big bag happened in 1753 ;)
			StringDateMap.Add("big bang", new DateTime(1753, 01, 01));
			//StringDateMap.Add( "millenium", new DateTime( 2000, 01, 01 ) );
			StringArray = StringSet.ToArray();
			StringList = new ArrayList(StringArray);
			IntArray = new int[] {1, 3, 3, 7};
			FooArray = new Foo[0];
			
			Customs = new ArrayList();
			Customs.Add(new String[] {"foo", "bar"});
			Customs.Add(new String[] {"A", "B"});
			Customs.Add(new String[] {"1", "2"});

			FooSet = new HashedSet<FooProxy>();
			Components = new FooComponent[]
				{
					new FooComponent("foo", 42, null, null),
					new FooComponent("bar", 88, null, new FooComponent("sub", 69, null, null))
				};
			TimeArray = new DateTime[]
				{
					new DateTime(),
					new DateTime(),
					new DateTime(), // H2.1 has null here, but it's illegal on .NET
					new DateTime(0)
				};

			Count = 667;
			Name = "Bazza";
			TopComponents = new ArrayList();
			TopComponents.Add(new FooComponent("foo", 11, new DateTime[] {today, new DateTime(2123, 1, 1)}, null));
			TopComponents.Add(
				new FooComponent("bar", 22, new DateTime[] {new DateTime(2007, 2, 3), new DateTime(1945, 6, 1)}, null));
			TopComponents.Add(null);
			Bag = new ArrayList();
			Bag.Add("duplicate");
			Bag.Add("duplicate");
			Bag.Add("duplicate");
			Bag.Add("unique");

			Cached = new OrderedSet<CompositeElement>();

			CompositeElement ce = new CompositeElement();
			ce.Foo = "foo";
			ce.Bar = "bar";
			CompositeElement ce2 = new CompositeElement();
			ce2.Foo = "fooxxx";
			ce2.Bar = "barxxx";
			Cached.Add(ce);
			Cached.Add(ce2);
			CachedMap = new SortedList();
			CachedMap.Add(this, ce);
		}
		public void ExistingModifiableAfterSetSessionReadOnly()
		{
			Container cOrig = CreateContainer();

			ISet<object> expectedInitializedObjects =
					new HashedSet<object>(
						new object[]
						{
							cOrig,
							//cOrig.NoProxyInfo,
							cOrig.ProxyInfo,
							cOrig.NonLazyInfo,
							//cOrig.NoProxyOwner,
							cOrig.ProxyOwner,
							cOrig.NonLazyOwner,
							cOrig.LazyDataPoints.First(),
							cOrig.NonLazyJoinDataPoints.First(),
							cOrig.NonLazySelectDataPoints.First()
						});

			ISet<object> expectedReadOnlyObjects = new HashedSet<object>();
	
			ISession s = OpenSession();
			Assert.That(s.DefaultReadOnly, Is.False);
			ITransaction t = s.BeginTransaction();
			s.Save(cOrig);
			CheckContainer(cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s);
			s.DefaultReadOnly = true;
			Assert.That(s.DefaultReadOnly, Is.True);
			CheckContainer(cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s);
			t.Commit();
	
			t = s.BeginTransaction();
			Assert.That(s.DefaultReadOnly, Is.True);
			CheckContainer(cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s);
			Container c = s.Load<Container>(cOrig.Id);
			Assert.That(cOrig, Is.SameAs(c));
			CheckContainer(c, expectedInitializedObjects, expectedReadOnlyObjects, s);
			c = s.Get<Container>(cOrig.Id);
			Assert.That(cOrig, Is.SameAs(c));
			CheckContainer(cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s);
			s.Refresh(cOrig);
			Assert.That(cOrig, Is.SameAs(c));
			CheckContainer(cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s);
			
			// NH-specific: The following line is required to evict DataPoint(Id=1) from the Container.LazyDataPoint collection.
			// This behaviour would seem to be necessary 'by design', as a comment in EvictCascadingAction states, "evicts don't
			// cascade to uninitialized collections".
			// If LazyDataPoint(Id=1) is not evicted, it has a status of Loaded, not ReadOnly, and causes the test to fail further
			// down.
			// Another way to get this test to pass is s.Clear().
			NHibernateUtil.Initialize(cOrig.LazyDataPoints);
			
			s.Evict(cOrig);

			c = s.Get<Container>(cOrig.Id);
			Assert.That(cOrig, Is.Not.SameAs(c));
		
			expectedInitializedObjects =
					new HashedSet<object>(
						new object[]
						{
							c,
							c.NonLazyInfo,
							//c.NoProxyOwner,
							c.ProxyOwner,
							c.NonLazyOwner,
							c.NonLazyJoinDataPoints.First(),
							c.NonLazySelectDataPoints.First()
						});
			
			expectedReadOnlyObjects =
					new HashedSet<object>(
						new object[]
						{
							c,
							//c.NoProxyInfo,
							c.ProxyInfo,
							c.NonLazyInfo,
							//c.NoProxyOwner,
							c.ProxyOwner,
							c.NonLazyOwner,
							//c.getLazyDataPoints(),
							c.NonLazyJoinDataPoints.First(),
							c.NonLazySelectDataPoints.First()
						});

			CheckContainer(c, expectedInitializedObjects, expectedReadOnlyObjects, s);
//			Assert.That(NHibernateUtil.IsInitialized(c.NoProxyInfo), Is.False);
//			NHibernateUtil.Initialize(c.NoProxyInfo);
//			expectedInitializedObjects.Add(c.NoProxyInfo);
//			CheckContainer(c, expectedInitializedObjects, expectedReadOnlyObjects, s);
			Assert.That(NHibernateUtil.IsInitialized(c.ProxyInfo), Is.False);
			NHibernateUtil.Initialize(c.ProxyInfo);
			expectedInitializedObjects.Add(c.ProxyInfo);
			CheckContainer(c, expectedInitializedObjects, expectedReadOnlyObjects, s);
			
			Assert.That(NHibernateUtil.IsInitialized(c.LazyDataPoints), Is.False);
			NHibernateUtil.Initialize(c.LazyDataPoints);
			expectedInitializedObjects.Add(c.LazyDataPoints.First());
			expectedReadOnlyObjects.Add(c.LazyDataPoints.First());
			
			// The following check fails if the NH-specific change (above) is not made. More specifically it fails
			// when asserting that the c.LazyDataPoints.First() is ReadOnly
			CheckContainer(c, expectedInitializedObjects, expectedReadOnlyObjects, s);
			
			t.Commit();
			s.Close();
			
			s = OpenSession();
			t = s.BeginTransaction();
			s.CreateQuery("delete from DataPoint").ExecuteUpdate();
			s.CreateQuery("delete from Container").ExecuteUpdate();
			s.CreateQuery("delete from Info").ExecuteUpdate();
			s.CreateQuery("delete from Owner").ExecuteUpdate();
			t.Commit();
			s.Close();
		}
		/// <summary>
		/// SQL UPDATE query
		/// <example>
		/// Example:
		/// <code>
		/// using  HyperNetDatabase.R2;
		/// ...
		/// Database  db  =  new  Database();
		/// db.Open("file.hnd");  //  creates  or  opens  database
		/// ...
		/// string StockName = "peppers";
		/// DataTable  result  =  db.Update("Stock", 
		/// new object[,]{ {"NAME",StockName}, {"QTY",0.5m} },
		/// new object[,]{ {"NAME","=","pepperoni"} } 
		/// );
		/// ...
		/// </code>
		/// Is the same as: UPDATE Stock SET NAME=@StockName, QTY=0.5 WHERE NAME=pepperoni 
		/// </example>	
		/// <code>
		/// 
		/// </code>
		/// <include file='../XML_DOC.xml' path='REPEATED_COMMENTS/WHERE_SINTAX/*' />	
		/// <code>
		/// 
		/// </code>
		/// <include file='../XML_DOC.xml' path='REPEATED_COMMENTS/SET_EXPRESSION/*' />	
		/// </summary>
		/// <param name="From_TableName"></param>
		/// <param name="Set">SET expression</param>
		/// <param name="Where_NameCondValue">WHERE expresion</param>
		/// <returns></returns>
		public void Update(string From_TableName, object[,] Set, object[,] Where_NameCondValue)
		{

				lock(this.TableBlocking)
				{
					this.RaiseExceptionIfClosed();
					string TableName=From_TableName;
					QueryCacheDestroy(TableName);


					// Build table fields without deletion field
					Hashtable htTableFields = new Hashtable(); 
					if(true)
					{
						Field[] flds = GetFields(TableName);
						foreach(Field f in flds) if(f.Name!=Database.DeletedFieldName) htTableFields[f.Name]=f;
					}

					// Check 'Set'
					Hashtable SetFields = new Hashtable();
					for(int n=0;n<Set.GetLength(0);n++)
					{
						string fname = Set[n,0].ToString();
						if(!htTableFields.ContainsKey(fname))
							throw new Exception("Field '"+fname+"' do not exist in this table.");
						if(SetFields.ContainsKey(fname))
							throw new Exception("Field '"+fname+"' is repeated in the set clause of this update command.");
						Field f = (htTableFields[fname] as Field);
						object val = Set[n,1];
						Variant v = Variant.Object2Variant( val, f.type );
						object obj = v.obj;
						SetFields[fname]=obj;
					}

					// Check constraints
					foreach(string fname in SetFields.Keys)
					{ 
						Field f = htTableFields[fname] as Field;
						if(f.bIndexed&&f.bUnique)
						{
							Index ndx = this.GetIndex(TableName,f);
							if(ndx.ExistsKey( SetFields[fname] ))
								throw new Exception("Insert violates '"+f.Name+"' field for table '"+TableName+"'.");
						}
					}

					// Get the rowids
					Set ROWIDS;
					ExecuteWhere(From_TableName,Where_NameCondValue,out ROWIDS);

					// Set fields
					if(ROWIDS==null) throw new Exception("Where condition returned null rows.");
					
					// Data set
					int tid = (int)TableName2TID[TableName];
					TableNameDef tnd = TID2Def[tid] as TableNameDef;

					// Create roll-back to prevent blackouts

					// make log file of old data
					string lfn = DatabaseFilePath+".hlg";
					FileStream lf;
					try
					{
						lf = new FileStream(lfn,FileMode.Create,FileAccess.Write,FileShare.None);
					}
					catch
					{
						throw new Exception("Insufficient disk space.");
					}
					BinaryWriter lfw=null;
					try
					{
						lfw = new BinaryWriter(lf,System.Text.Encoding.Unicode);
						lfw.Write( (bool)false ); // not valid
						lfw.Flush();
						lfw.Write( (byte)1 ); // overwrite pages operation 
						Set PAGES = new HashedSet();
						foreach(string name in SetFields.Keys)
						{
							Field f = htTableFields[name] as Field;
							int valSize = (int)f.DataSize();
							long Capacity = (PageSize-ContentPageDataOffset)/valSize;
							ArrayList pages = f.DataFID;
							foreach(long rowid in ROWIDS)
							{
								long npage = rowid / Capacity;
								int page = (int)pages[(int)npage];
								PAGES.Add( page );
							}
						}
						lfw.Write( (int)PAGES.Count ); // num of pages involved
						foreach(int page in PAGES)
						{
							br.BaseStream.Position = (page*PageSize);
							byte[] buf = br.ReadBytes( Database.PageSize );
							lfw.Write( (int)page ); // page id
							lfw.Write( buf ); // page
						}
						lfw.Flush();
						try
						{
							lfw.BaseStream.Position=0;
							lfw.Write( (bool)true ); // valid
							lfw.Flush();
						}
						catch
						{
							// aborting log file
							try
							{
								lfw.BaseStream.SetLength(0);
							}
							catch
							{
							}
							throw;
						}
					}
					catch
					{
						try
						{
							if(lfw!=null)
								lfw.Close();
						}
						catch
						{
						}
						throw new Exception("Error while writing rollback, update operation cancelled. (Insufficient disk space?)");
					}

					// Do the changes
					foreach(string name in SetFields.Keys)
					{	
						Field f = htTableFields[name] as Field;
						int valSize = (int)f.DataSize();
						long Capacity = (PageSize-ContentPageDataOffset)/valSize;
						ArrayList pages = f.DataFID;
						if((pages.Count*Capacity)<tnd.rownum)
							throw new Exception("Row num corrupted.");


						foreach(long rowid in ROWIDS)
						{
							object oldkey;
							try
							{
								long npage = rowid / Capacity;
								long offset = rowid % Capacity;
								int page = (int)pages[(int)npage];
								//br.BaseStream.Position = (page*PageSize)+ContentPageDataOffset+offset*valSize;
								//oldkey = f.ReadData(br);
								oldkey = f.ReadData( this.PageReader(page,ContentPageDataOffset+offset*valSize) );
								br.BaseStream.Position = (page*PageSize)+ContentPageDataOffset+offset*valSize;
								Variant v = Variant.Object2Variant( SetFields[f.Name], f.type);
								f.WriteData(bw,v,false); // CAUTION
								this.InvalidatePage(page);
							}
							catch(Exception ex)
							{
								this.Close();
								this.LogToFile(ex.Message,ex.StackTrace);
								throw new Exception("Fatal error while writting data into database.");
							}

							if(f.bIndexed)
							{
								Index ndx;
								try
								{
									ndx = GetIndex(TableName,f);
								}
								catch(Exception ex)
								{
									this.Close();
									this.LogToFile(ex.Message,ex.StackTrace);
									throw new Exception("Fatal error while reading index database.");
								}
								object key = SetFields[f.Name];
								try
								{	
									if((key as IComparable).CompareTo(oldkey as IComparable)!=0)
									{
										//if(f.type==FieldType.ftDateTime)
											ndx.RemoveByRowid(rowid);
										//else
											ndx.Add(key,rowid,f.Name);
									}
								}
								catch(Exception ex)
								{
									this.Close();
									this.LogToFile(ex.Message,ex.StackTrace);
									throw new Exception("Fatal error while changing key. Table:"+TableName+", Field:"+f.Name+", OldKey:"+oldkey.ToString()+", NewKey:"+key.ToString()+".");
								}
							}
						}
						bw.BaseStream.Flush();
					}

					// clear log
					lfw.BaseStream.SetLength(0);
					lfw.Flush();
					lfw.Close();
				}

		}
		public void ExistingReadOnlyAfterSetSessionModifiableExistingProxyReadOnly()
		{
			Container cOrig = CreateContainer();
			ISet<object> expectedInitializedObjects =
					new HashedSet<object>(
						new object[]
						{
							cOrig,
							//cOrig.NoProxyInfo,
							cOrig.ProxyInfo,
							cOrig.NonLazyInfo,
							//cOrig.NoProxyOwner,
							cOrig.ProxyOwner,
							cOrig.NonLazyOwner,
							cOrig.LazyDataPoints.First(),
							cOrig.NonLazyJoinDataPoints.First(),
							cOrig.NonLazySelectDataPoints.First()
						});

			ISet<object> expectedReadOnlyObjects = new HashedSet<object>();
			DataPoint lazyDataPointOrig = cOrig.LazyDataPoints.First();
			ISession s = OpenSession();
			Assert.That(s.DefaultReadOnly, Is.False);
			ITransaction t = s.BeginTransaction();
			s.Save(cOrig);
			CheckContainer(cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s);
			s.DefaultReadOnly = true;
			Assert.That(s.DefaultReadOnly, Is.True);
			CheckContainer(cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s);
			t.Commit();
			s.Close();
	
			s = OpenSession();
			t = s.BeginTransaction();
			s.DefaultReadOnly = true;
			Container c = s.Get<Container>(cOrig.Id);
			Assert.That(cOrig, Is.Not.SameAs(c));
			
			expectedInitializedObjects =
					new HashedSet<object>(
						new object[]
						{
							c,
							c.NonLazyInfo,
							//c.NoProxyOwner,
							c.ProxyOwner,
							c.NonLazyOwner,
							c.NonLazyJoinDataPoints.First(),
							c.NonLazySelectDataPoints.First()
						});

			expectedReadOnlyObjects =
					new HashedSet<object>(
						new object[]
						{
							c,
							//c.NoProxyInfo,
							c.ProxyInfo,
							c.NonLazyInfo,
							//c.NoProxyOwner,
							c.ProxyOwner,
							c.NonLazyOwner,
							//c.getLazyDataPoints(),
							c.NonLazyJoinDataPoints.First(),
							c.NonLazySelectDataPoints.First()
						});

			CheckContainer(c, expectedInitializedObjects, expectedReadOnlyObjects, s);
			s.DefaultReadOnly = false;
			CheckContainer(c, expectedInitializedObjects, expectedReadOnlyObjects, s);
//			Assert.That(NHibernateUtil.IsInitialized(c.NoProxyInfo), Is.False);
//			NHibernateUtil.Initialize(c.NoProxyInfo);
//			expectedInitializedObjects.Add(c.NoProxyInfo);
//			CheckContainer(c, expectedInitializedObjects, expectedReadOnlyObjects, s);
			Assert.That(NHibernateUtil.IsInitialized(c.ProxyInfo), Is.False);
			NHibernateUtil.Initialize(c.ProxyInfo);
			expectedInitializedObjects.Add(c.ProxyInfo);
			CheckContainer(c, expectedInitializedObjects, expectedReadOnlyObjects, s);
			s.DefaultReadOnly = true;
			DataPoint lazyDataPoint = s.Load<DataPoint>(lazyDataPointOrig.Id);
			s.DefaultReadOnly = false;
			Assert.That(NHibernateUtil.IsInitialized(c.LazyDataPoints), Is.False);
			NHibernateUtil.Initialize(c.LazyDataPoints);
			Assert.That(lazyDataPoint, Is.SameAs(c.LazyDataPoints.First()));
			expectedInitializedObjects.Add(c.LazyDataPoints.First());
			expectedReadOnlyObjects.Add(lazyDataPoint);
			CheckContainer(c, expectedInitializedObjects, expectedReadOnlyObjects, s);
			t.Commit();
			s.Close();
			s = OpenSession();
			t = s.BeginTransaction();
			s.CreateQuery("delete from DataPoint").ExecuteUpdate();
			s.CreateQuery("delete from Container").ExecuteUpdate();
			s.CreateQuery("delete from Info").ExecuteUpdate();
			s.CreateQuery("delete from Owner").ExecuteUpdate();
			t.Commit();
			s.Close();
		}
Beispiel #27
0
 protected internal virtual void CheckColumnDuplication()
 {
     HashedSet<string> cols = new HashedSet<string>();
     if (IdentifierMapper == null)
     {
         //an identifier mapper => Key will be included in the NonDuplicatedPropertyIterator
         //and checked later, so it needs to be excluded
         CheckColumnDuplication(cols, Key.ColumnIterator);
     }
     CheckColumnDuplication(cols, DiscriminatorColumnIterator);
     CheckPropertyColumnDuplication(cols, NonDuplicatedPropertyIterator);
     foreach (Join join in JoinIterator)
     {
         cols.Clear();
         CheckColumnDuplication(cols, join.Key.ColumnIterator);
         CheckPropertyColumnDuplication(cols, join.PropertyIterator);
     }
 }
		public void DefaultModifiableWithQueryForEntity()
		{
			Container cOrig = CreateContainer();
			ISet<object> expectedInitializedObjects =
					new HashedSet<object>(
						new object[]
						{
							cOrig,
							//cOrig.NoProxyInfo,
							cOrig.ProxyInfo,
							cOrig.NonLazyInfo,
							//cOrig.NoProxyOwner,
							cOrig.ProxyOwner,
							cOrig.NonLazyOwner,
							cOrig.LazyDataPoints.First(),
							cOrig.NonLazyJoinDataPoints.First(),
							cOrig.NonLazySelectDataPoints.First()
						});

			ISet<object> expectedReadOnlyObjects = new HashedSet<object>();
	
			ISession s = OpenSession();
			Assert.That(s.DefaultReadOnly, Is.False);
			ITransaction t = s.BeginTransaction();
			s.Save(cOrig);
			CheckContainer(cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s);
			s.DefaultReadOnly = true;
			Assert.That(s.DefaultReadOnly, Is.True);
			CheckContainer(cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s);
			t.Commit();
			s.Close();
	
			s = OpenSession();
			t = s.BeginTransaction();
			Assert.That(s.DefaultReadOnly, Is.False);
			Container c = s.CreateQuery("from Container where id=" + cOrig.Id).UniqueResult<Container>();
			expectedInitializedObjects =
					new HashedSet<object>(
						new object[]
						{
							c,
							c.NonLazyInfo,
							//c.NoProxyOwner,
							c.ProxyOwner,
							c.NonLazyOwner,
							c.NonLazyJoinDataPoints.First(),
							c.NonLazySelectDataPoints.First()
						});

			expectedReadOnlyObjects = new HashedSet<object>();
			CheckContainer(c, expectedInitializedObjects, expectedReadOnlyObjects, s);
//			Assert.That(NHibernateUtil.IsInitialized(c.NoProxyInfo), Is.False);
//			NHibernateUtil.Initialize(c.NoProxyInfo);
//			expectedInitializedObjects.Add(c.NoProxyInfo);
//			CheckContainer(c, expectedInitializedObjects, expectedReadOnlyObjects, s);
			Assert.That(NHibernateUtil.IsInitialized(c.ProxyInfo), Is.False);
			NHibernateUtil.Initialize(c.ProxyInfo);
			expectedInitializedObjects.Add(c.ProxyInfo);
			CheckContainer(c, expectedInitializedObjects, expectedReadOnlyObjects, s);
			Assert.That(NHibernateUtil.IsInitialized(c.LazyDataPoints), Is.False);
			NHibernateUtil.Initialize(c.LazyDataPoints);
			expectedInitializedObjects.Add(c.LazyDataPoints.First());
			//expectedReadOnlyObjects.Add(c.LazyDataPoints.First());
			CheckContainer(c, expectedInitializedObjects, expectedReadOnlyObjects, s);
			t.Commit();
			s.Close();
			s = OpenSession();
			t = s.BeginTransaction();
			s.CreateQuery("delete from DataPoint").ExecuteUpdate();
			s.CreateQuery("delete from Container").ExecuteUpdate();
			s.CreateQuery("delete from Info").ExecuteUpdate();
			s.CreateQuery("delete from Owner").ExecuteUpdate();
			t.Commit();
			s.Close();
		}
		protected internal virtual SqlString GenerateLazySelectString()
		{
			if (!entityMetamodel.HasLazyProperties)
				return null;

			HashedSet<int> tableNumbers = new HashedSet<int>();
			List<int> columnNumbers = new List<int>();
			List<int> formulaNumbers = new List<int>();
			for (int i = 0; i < lazyPropertyNames.Length; i++)
			{
				// all this only really needs to consider properties
				// of this class, not its subclasses, but since we
				// are reusing code used for sequential selects, we
				// use the subclass closure
				int propertyNumber = GetSubclassPropertyIndex(lazyPropertyNames[i]);

				int tableNumber = GetSubclassPropertyTableNumber(propertyNumber);
				tableNumbers.Add(tableNumber);

				int[] colNumbers = subclassPropertyColumnNumberClosure[propertyNumber];
				for (int j = 0; j < colNumbers.Length; j++)
				{
					if (colNumbers[j] != -1)
					{
						columnNumbers.Add(colNumbers[j]);
					}
				}
				int[] formNumbers = subclassPropertyFormulaNumberClosure[propertyNumber];
				for (int j = 0; j < formNumbers.Length; j++)
				{
					if (formNumbers[j] != -1)
					{
						formulaNumbers.Add(formNumbers[j]);
					}
				}
			}

			if (columnNumbers.Count == 0 && formulaNumbers.Count == 0)
			{
				// only one-to-one is lazy fetched
				return null;
			}

			return RenderSelect(tableNumbers.ToArray(), columnNumbers.ToArray(), formulaNumbers.ToArray());
		}
		private IDictionary<string, string[]> BindPropertyResults(string alias, HbmReturnDiscriminator discriminatorSchema,
			HbmReturnProperty[] returnProperties, PersistentClass pc)
		{
			Dictionary<string, string[]> propertyresults = new Dictionary<string, string[]>();
			// maybe a concrete SQLpropertyresult type, but Map is exactly what is required at the moment

			if (discriminatorSchema != null)
			{
				propertyresults["class"] = GetResultColumns(discriminatorSchema).ToArray();
			}

			List<HbmReturnProperty> properties = new List<HbmReturnProperty>();
			List<string> propertyNames = new List<string>();

			foreach (HbmReturnProperty returnPropertySchema in returnProperties ?? new HbmReturnProperty[0])
			{
				string name = returnPropertySchema.name;
				if (pc == null || name.IndexOf('.') == -1)
				{
					//if dotted and not load-collection nor return-join
					//regular property
					properties.Add(returnPropertySchema);
					propertyNames.Add(name);
				}
				else
				{
					// Reorder properties
					// 1. get the parent property
					// 2. list all the properties following the expected one in the parent property
					// 3. calculate the lowest index and insert the property

					int dotIndex = name.LastIndexOf('.');
					string reducedName = name.Substring(0, dotIndex);
					IValue value = pc.GetRecursiveProperty(reducedName).Value;
					IEnumerable<Mapping.Property> parentPropIter;
					if (value is Component)
					{
						Component comp = (Component) value;
						parentPropIter = comp.PropertyIterator;
					}
					else if (value is ToOne)
					{
						ToOne toOne = (ToOne) value;
						PersistentClass referencedPc = mappings.GetClass(toOne.ReferencedEntityName);
						if (toOne.ReferencedPropertyName != null)
							try
							{
								parentPropIter =
									((Component) referencedPc.GetRecursiveProperty(toOne.ReferencedPropertyName).Value).PropertyIterator;
							}
							catch (InvalidCastException e)
							{
								throw new MappingException("dotted notation reference neither a component nor a many/one to one", e);
							}
						else
							try
							{
								parentPropIter = ((Component) referencedPc.IdentifierProperty.Value).PropertyIterator;
							}
							catch (InvalidCastException e)
							{
								throw new MappingException("dotted notation reference neither a component nor a many/one to one", e);
							}
					}
					else
						throw new MappingException("dotted notation reference neither a component nor a many/one to one");
					bool hasFollowers = false;
					List<string> followers = new List<string>();
					foreach (Mapping.Property prop in parentPropIter)
					{
						string currentPropertyName = prop.Name;
						string currentName = reducedName + '.' + currentPropertyName;
						if (hasFollowers)
							followers.Add(currentName);
						if (name.Equals(currentName))
							hasFollowers = true;
					}

					int index = propertyNames.Count;
					int followersSize = followers.Count;
					for (int loop = 0; loop < followersSize; loop++)
					{
						string follower = followers[loop];
						int currentIndex = GetIndexOfFirstMatchingProperty(propertyNames, follower);
						index = currentIndex != -1 && currentIndex < index ? currentIndex : index;
					}
					propertyNames.Insert(index, name);
					properties.Insert(index, returnPropertySchema);
				}
			}

			ISet<string> uniqueReturnProperty = new HashedSet<string>();
			foreach (HbmReturnProperty returnPropertySchema in properties)
			{
				string name = returnPropertySchema.name;
				if ("class".Equals(name))
					throw new MappingException(
						"class is not a valid property name to use in a <return-property>, use <return-discriminator> instead"
						);
				//TODO: validate existing of property with the chosen name. (secondpass )
				List<string> allResultColumns = GetResultColumns(returnPropertySchema);

				if (allResultColumns.Count == 0)
					throw new MappingException(
						"return-property for alias " + alias +
							" must specify at least one column or return-column name"
						);
				if (uniqueReturnProperty.Contains(name))
					throw new MappingException(
						"duplicate return-property for property " + name +
							" on alias " + alias
						);
				uniqueReturnProperty.Add(name);

				// the issue here is that for <return-join/> representing an entity collection,
				// the collection element values (the property values of the associated entity)
				// are represented as 'element.{propertyname}'.  Thus the StringHelper.root()
				// here puts everything under 'element' (which additionally has significant
				// meaning).  Probably what we need to do is to something like this instead:
				//      String root = StringHelper.root( name );
				//      String key = root; // by default
				//      if ( !root.equals( name ) ) {
				//	        // we had a dot
				//          if ( !root.equals( alias ) {
				//              // the root does not apply to the specific alias
				//              if ( "elements".equals( root ) {
				//                  // we specifically have a <return-join/> representing an entity collection
				//                  // and this <return-property/> is one of that entity's properties
				//                  key = name;
				//              }
				//          }
				//      }
				// but I am not clear enough on the intended purpose of this code block, especially
				// in relation to the "Reorder properties" code block above... 
				//			String key = StringHelper.root( name );
				string key = name;
				string[] intermediateResults;
				if (!propertyresults.TryGetValue(key,out intermediateResults))
					propertyresults[key] = allResultColumns.ToArray();
				else
					ArrayHelper.AddAll(intermediateResults, allResultColumns); // TODO: intermediateResults not used after this
			}

			Dictionary<string, string[]> newPropertyResults = new Dictionary<string, string[]>();

			foreach (KeyValuePair<string, string[]> entry in propertyresults)
			{
				newPropertyResults[entry.Key] = entry.Value;
			}
			return newPropertyResults.Count == 0 ? (IDictionary<string, string[]>)new CollectionHelper.EmptyMapClass<string, string[]>() : newPropertyResults;
		}