Index: /trunk/sources/HeuristicLab.CEDMA.Core/Console.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Core/Console.cs	(revision 1416)
+++ /trunk/sources/HeuristicLab.CEDMA.Core/Console.cs	(revision 1417)
@@ -32,7 +32,4 @@
 namespace HeuristicLab.CEDMA.Core {
   public class Console : ItemBase, IEditable {
-    private DataSetList dataSetList;
-    private ChannelFactory<IStore> factory;
-    private IStore store;
     private string serverUri;
     public string ServerUri {
@@ -40,4 +37,5 @@
     }
 
+    private DataSetList dataSetList;
     public DataSetList DataSetList {
       get { return dataSetList; }
@@ -72,20 +70,6 @@
     #endregion
 
-    #region WCF
-    private void ResetConnection() {
-      NetTcpBinding binding = new NetTcpBinding();
-      binding.ReceiveTimeout = new TimeSpan(1, 0, 0);
-      binding.MaxReceivedMessageSize = 1000000000; // 100Mbytes
-      binding.ReaderQuotas.MaxStringContentLength = 1000000000; // also 100M chars
-      binding.ReaderQuotas.MaxArrayLength = 1000000000; // also 100M elements;
-      factory = new ChannelFactory<IStore>(binding);
-      store = factory.CreateChannel(new EndpointAddress(serverUri));
-      dataSetList.Store = store;
-    }
-    #endregion
-
     internal void Connect(string serverUri) {
-      this.serverUri = serverUri;
-      ResetConnection();
+      DataSetList.Store = new StoreProxy(serverUri);
     }
   }
Index: /trunk/sources/HeuristicLab.CEDMA.Core/DataSet.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Core/DataSet.cs	(revision 1416)
+++ /trunk/sources/HeuristicLab.CEDMA.Core/DataSet.cs	(revision 1417)
@@ -49,9 +49,6 @@
         // lazy loading of problem from DB
         if (problem == null) {
-          //var serializedDataVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("SerializedData");
-          //var persistedData = Store.Query(
-          //  new Statement[] { new Statement(new Entity(Ontology.CedmaNameSpace + Guid), Ontology.PredicateSerializedData, serializedDataVar)});
           var persistedData = Store.Query(
-            "<" + Ontology.CedmaNameSpace + Guid + "> <" + Ontology.PredicateSerializedData.Uri + "> ?SerializedData .");
+            "<" + Ontology.CedmaNameSpace + Guid + "> <" + Ontology.PredicateSerializedData.Uri + "> ?SerializedData .", 0, 10);
           if (persistedData.Count() == 1) {
             Literal persistedLiteral = (Literal)persistedData.First().Get("SerializedData");
Index: /trunk/sources/HeuristicLab.CEDMA.Core/DataSetList.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Core/DataSetList.cs	(revision 1416)
+++ /trunk/sources/HeuristicLab.CEDMA.Core/DataSetList.cs	(revision 1417)
@@ -62,9 +62,5 @@
       var bindings = store.Query(
         "?DataSet <"+Ontology.PredicateInstanceOf.Uri+"> <"+Ontology.TypeDataSet.Uri+"> ." + Environment.NewLine +
-        "?DataSet <"+Ontology.PredicateName.Uri+"> ?Name .");
-      //  new Statement[] { 
-      //    new Statement(dataSetVar, Ontology.PredicateInstanceOf, Ontology.TypeDataSet),
-      //    new Statement(dataSetVar, Ontology.PredicateName, dataSetNameVar)
-      //});
+        "?DataSet <"+Ontology.PredicateName.Uri+"> ?Name .",0, 100);
       foreach (var binding in bindings) {
         DataSet d = new DataSet(store, (Entity)binding.Get("DataSet"));
Index: /trunk/sources/HeuristicLab.CEDMA.Core/HeuristicLab.CEDMA.Core.csproj
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Core/HeuristicLab.CEDMA.Core.csproj	(revision 1416)
+++ /trunk/sources/HeuristicLab.CEDMA.Core/HeuristicLab.CEDMA.Core.csproj	(revision 1417)
@@ -72,4 +72,5 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="StoreProxy.cs" />
     <Compile Include="IResultsViewFactory.cs" />
     <Compile Include="ResultsEntry.cs" />
Index: /trunk/sources/HeuristicLab.CEDMA.Core/Results.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Core/Results.cs	(revision 1416)
+++ /trunk/sources/HeuristicLab.CEDMA.Core/Results.cs	(revision 1417)
@@ -37,4 +37,5 @@
 namespace HeuristicLab.CEDMA.Core {
   public class Results : ItemBase {
+    private const int PAGE_SIZE = 1000;
     private string[] categoricalVariables = null;
     public string[] CategoricalVariables {
@@ -84,23 +85,37 @@
 
     private IEnumerable<ResultsEntry> SelectRows() {
+      int page = 0;
+      int resultsReturned = 0;
+      bool newEntry = false;
       if (store == null) yield break;
       entries = new List<ResultsEntry>();
-      var results = store.Query("<" + dataSetEntity + "> <" + Ontology.PredicateHasModel + "> ?Model ." + Environment.NewLine +
-        "?Model ?Attribute ?Value .")
-        .GroupBy(x => (Entity)x.Get("Model"));
-      foreach (var modelBindings in results) {
-        ResultsEntry entry = new ResultsEntry(modelBindings.Key.Uri);
-        foreach (var binding in modelBindings) {
-          if (binding.Get("Value") is Literal) {
-            string name = ((Entity)binding.Get("Attribute")).Uri.Replace(Ontology.CedmaNameSpace, "");
-            if (entry.Get(name) == null) {
-              object value = ((Literal)binding.Get("Value")).Value;
-              entry.Set(name, value);
+      do {
+        var allBindings = store.Query("<" + dataSetEntity + "> <" + Ontology.PredicateHasModel + "> ?Model ." + Environment.NewLine +
+          "?Model ?Attribute ?Value .", page, PAGE_SIZE);
+        var allModelBindings = allBindings.GroupBy(x => (Entity)x.Get("Model"));
+        resultsReturned = allBindings.Count;
+
+        foreach (var modelBindings in allModelBindings) {
+          ResultsEntry entry = entries.FirstOrDefault(x => x.Uri == modelBindings.Key.Uri);
+          newEntry = false;
+          if (entry == null) {
+            entry = new ResultsEntry();
+            entry.Uri = modelBindings.Key.Uri;
+            entries.Add(entry);
+            newEntry = true;
+          }
+          foreach (var binding in modelBindings) {
+            if (binding.Get("Value") is Literal) {
+              string name = ((Entity)binding.Get("Attribute")).Uri.Replace(Ontology.CedmaNameSpace, "");
+              if (entry.Get(name) == null) {
+                object value = ((Literal)binding.Get("Value")).Value;
+                entry.Set(name, value);
+              }
             }
           }
+          if (newEntry) yield return entry;
         }
-        entries.Add(entry);
-        yield return entry;
-      }
+        page++;
+      } while (resultsReturned == PAGE_SIZE);
 
       FireChanged();
@@ -114,9 +129,9 @@
     private void LoadModelAttributes() {
       this.ordinalVariables =
-        store.Query("?ModelAttribute <" + Ontology.PredicateInstanceOf + "> <" + Ontology.TypeOrdinalAttribute + "> .")
+        store.Query("?ModelAttribute <" + Ontology.PredicateInstanceOf + "> <" + Ontology.TypeOrdinalAttribute + "> .", 0, 100)
         .Select(s => ((Entity)s.Get("ModelAttribute")).Uri.Replace(Ontology.CedmaNameSpace, ""))
         .ToArray();
       this.categoricalVariables =
-        store.Query("?ModelAttribute <" + Ontology.PredicateInstanceOf + "> <" + Ontology.TypeCategoricalAttribute + "> .")
+        store.Query("?ModelAttribute <" + Ontology.PredicateInstanceOf + "> <" + Ontology.TypeCategoricalAttribute + "> .", 0, 100)
         .Select(s => ((Entity)s.Get("ModelAttribute")).Uri.Replace(Ontology.CedmaNameSpace, ""))
         .ToArray();
Index: /trunk/sources/HeuristicLab.CEDMA.Core/ResultsEntry.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Core/ResultsEntry.cs	(revision 1416)
+++ /trunk/sources/HeuristicLab.CEDMA.Core/ResultsEntry.cs	(revision 1417)
@@ -43,8 +43,7 @@
 
     private string uri;
-    public string Uri { get { return uri; } }
-
-    public ResultsEntry(string uri) {
-      this.uri = uri;
+    public string Uri { 
+      get { return uri; }
+      set { uri = value; }
     }
 
Index: /trunk/sources/HeuristicLab.CEDMA.Core/StoreProxy.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Core/StoreProxy.cs	(revision 1417)
+++ /trunk/sources/HeuristicLab.CEDMA.Core/StoreProxy.cs	(revision 1417)
@@ -0,0 +1,92 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+using System.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using System.ServiceModel.Channels;
+
+namespace HeuristicLab.CEDMA.Core {
+  public class StoreProxy : IStore {
+    private string serverUri;
+    private IStore store;
+    private NetTcpBinding binding;
+
+    public StoreProxy(string serverUri) {
+      this.serverUri = serverUri;
+      Reset();
+      Reconnect();
+    }
+
+    private void Reset() {
+      binding = new NetTcpBinding();
+      binding.ReceiveTimeout = new TimeSpan(1, 0, 0);
+      binding.MaxReceivedMessageSize = int.MaxValue;
+      binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
+      binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
+    }
+
+    private void Reconnect() {
+      ChannelFactory<IStore> factory = new ChannelFactory<IStore>(binding);
+      store = factory.CreateChannel(new EndpointAddress(serverUri));
+    }
+
+    private void ExecuteSavely(Action a) {
+      ExecuteSavely(a);
+    }
+
+    private T ExecuteSavely<T>(Func<T> a ) {
+      try {
+        return a();
+      }
+      catch (CommunicationException) {
+        Reconnect();
+        return a();
+      }
+      catch (TimeoutException) {
+        Reconnect();
+        return a();
+      }
+    }
+
+    #region IStore Members
+
+    public void Add(Statement statement) {
+      ExecuteSavely(() => store.Add(statement));
+    }
+
+    public ICollection<VariableBindings> Query(ICollection<Statement> query, int page, int pageSize) {
+      return ExecuteSavely(() => store.Query(query, page, pageSize));
+    }
+
+    public ICollection<VariableBindings> Query(string query, int page, int pageSize) {
+      return ExecuteSavely(() => store.Query(query, page, pageSize));
+    }
+
+    #endregion
+  }
+}
Index: /trunk/sources/HeuristicLab.CEDMA.DB.Interfaces/IStore.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.DB.Interfaces/IStore.cs	(revision 1416)
+++ /trunk/sources/HeuristicLab.CEDMA.DB.Interfaces/IStore.cs	(revision 1417)
@@ -35,8 +35,8 @@
 
     [OperationContract]
-    ICollection<VariableBindings> Query(ICollection<Statement> query);
+    ICollection<VariableBindings> Query(ICollection<Statement> query, int page, int pageSize);
 
     [OperationContract(Name="QueryN3")]
-    ICollection<VariableBindings> Query(string query);
+    ICollection<VariableBindings> Query(string query, int page, int pageSize);
   }
 }
Index: /trunk/sources/HeuristicLab.CEDMA.DB/Store.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.DB/Store.cs	(revision 1416)
+++ /trunk/sources/HeuristicLab.CEDMA.DB/Store.cs	(revision 1417)
@@ -62,16 +62,16 @@
 
 
-    public ICollection<VariableBindings> Query(string query) {
+    public ICollection<VariableBindings> Query(string query, int page, int pageSize) {
       MyQueryResultSink resultSink = new MyQueryResultSink();
       SemWeb.N3Reader n3Reader = new SemWeb.N3Reader(new StringReader(query));
       SemWeb.Query.GraphMatch matcher = new SemWeb.Query.GraphMatch(n3Reader);
       matcher.Run(store, resultSink);
-      return resultSink.Bindings;
-    }
-
-    public ICollection<VariableBindings> Query(ICollection<Statement> query) {
+      return resultSink.Bindings.Skip(page*pageSize).Take(pageSize).ToList();
+    }
+
+    public ICollection<VariableBindings> Query(ICollection<Statement> query, int page, int pageSize) {
       MyQueryResultSink resultSink = new MyQueryResultSink();
       Translate(query).Run(store, resultSink);
-      return resultSink.Bindings;
+      return resultSink.Bindings.Skip(page * pageSize).Take(pageSize).ToList();
     }
 
@@ -82,29 +82,4 @@
       return new SemWeb.Query.GraphMatch(queryStore);
     }
-
-
-    //public ICollection<Statement> Select(Statement template) {
-    //  SemWeb.MemoryStore memStore = new SemWeb.MemoryStore();
-    //  lock (bigLock) {
-    //    store.Select(Translate(template), memStore);
-    //  }
-    //  return memStore.Select(x=>Translate(x)).ToList();
-    //}
-
-    //public ICollection<Statement> Select(SelectFilter filter) {
-    //  SemWeb.MemoryStore memStore = new SemWeb.MemoryStore();
-    //  lock (bigLock) {
-    //    store.Select(Translate(filter), memStore);
-    //  }
-    //  return memStore.Select(x => Translate(x)).ToList();
-    //}
-
-    //private SemWeb.SelectFilter Translate(SelectFilter filter) {
-    //  SemWeb.SelectFilter f = new SemWeb.SelectFilter();
-    //  f.Subjects = Array.ConvertAll(filter.Subjects, s => Translate(s));
-    //  f.Predicates = Array.ConvertAll(filter.Predicates, p => Translate(p));
-    //  f.Objects = Array.ConvertAll(filter.Properties, prop => Translate(prop));
-    //  return f;
-    //}
 
     private static SemWeb.Entity Translate(Entity e) {
Index: /trunk/sources/HeuristicLab.CEDMA.Server/DispatcherBase.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/DispatcherBase.cs	(revision 1416)
+++ /trunk/sources/HeuristicLab.CEDMA.Server/DispatcherBase.cs	(revision 1417)
@@ -68,5 +68,5 @@
       };
 
-      Entity[] datasets = store.Query("?DataSet <" + Ontology.PredicateInstanceOf.Uri + "> <" + Ontology.TypeDataSet.Uri + "> .")
+      Entity[] datasets = store.Query("?DataSet <" + Ontology.PredicateInstanceOf.Uri + "> <" + Ontology.TypeDataSet.Uri + "> .", 0, 100)
         .Select(x => (Entity)x.Get("DataSet"))
         .ToArray();
Index: /trunk/sources/HeuristicLab.CEDMA.Server/Server.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/Server.cs	(revision 1416)
+++ /trunk/sources/HeuristicLab.CEDMA.Server/Server.cs	(revision 1417)
@@ -71,8 +71,8 @@
       try {
         NetTcpBinding binding = new NetTcpBinding();
-        binding.SendTimeout = new TimeSpan(1, 0, 0);
-        binding.MaxReceivedMessageSize = 1000000000; // 100Mbytes
-        binding.ReaderQuotas.MaxStringContentLength = 1000000000; // also 100M chars
-        binding.ReaderQuotas.MaxArrayLength = 1000000000; // also 100M elements;
+        binding.SendTimeout = new TimeSpan(10, 0, 0);
+        binding.MaxReceivedMessageSize = int.MaxValue;
+        binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
+        binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
         host.AddServiceEndpoint(typeof(IStore), binding, cedmaServiceUrl);
         host.Open();
