Commits

Mike Podonyi committed acfc510

reverted RepositoryBase to previous state, RepositoryBase needs proper Unit Test and has to become stable with caching before to move on, compare with revision 44 for possible changes

Comments (0)

Files changed (1)

src/Empi.Camino/Data/RepositoryBase.cs

         /// Return all instances of type T.
         /// </summary>
         /// <returns></returns>
-        internal IEnumerable<TEntity> All()
+        internal IQueryable<TEntity> All()
         {
-            return GetTable();  //MP: should not work so
+            return GetTable();
         }
 
         /// <summary>
         /// </summary>
         /// <param name="exp"></param>
         /// <returns></returns>
-        internal IQueryable<TEntity> FindAll(Expression<Func<TEntity, bool>> exp)
+        internal IEnumerable<TEntity> FindAll(Expression<Func<TEntity, bool>> exp)
         {
             return GetTable().Where<TEntity>(exp);
         }
             return GetTable().Single(exp);
         }
 
-        //internal TEntity Single(Expression<Func<TEntity, bool>> exp, Type type)
-        //{
-        //    return GetTable(type)..Single(exp);
-        //}
-
-        internal TEntity SingleOrDefault(Expression<Func<TEntity, bool>> exp, Type type)
+        internal TEntity Single(Expression<Func<TEntity, bool>> exp, Type type)
         {
-            return GetTable(type).OfType<TEntity>().SingleOrDefault(exp);
+            return GetTable(type).Single(exp);
         }
 
         internal TEntity First(Expression<Func<TEntity, bool>> exp)
             return GetTable().First(exp);
         }
 
-        //internal TEntity First(Expression<Func<TEntity, bool>> exp, Type type)
-        //{
-        //    return GetTable(type).First(exp);
-        //}
+        internal TEntity First(Expression<Func<TEntity, bool>> exp, Type type)
+        {
+            return GetTable(type).First(exp);
+        }
 
         internal virtual void MarkForDeletion(TEntity entity)
         {
             return dataContextFactory.DataContext.GetTable<TEntity>();
         }
 
-        private ITable GetTable(Type type)
+        private Table<TEntity> GetTable(Type type)
         {
-           // return ((Table<TEntity>)dataContextFactory.DataContext.GetTable(type).Cast<Table<TEntity>>());
-
-            return dataContextFactory.DataContext.GetTable(type);//.OfType<TEntity>() as Table<TEntity>;
-
-
-            //return dataContextFactory.DataContext.GetTable(type); 
+             return ((Table<TEntity>) dataContextFactory.DataContext.GetTable(type)); 
         }
 
         private System.Data.Linq.Mapping.MetaTable TableMetadata