public Repository(ccEntities objectContext)
 {
     _objectContext = objectContext as ccEntities;
     _objectSet     = objectContext.CreateObjectSet <T>();
     _objectContext.SavingChanges      += new EventHandler(_objectContext_SavingChanges);
     _objectContext.ObjectMaterialized += new ObjectMaterializedEventHandler(_objectContext_ObjectMaterialized);
 }
 HelpTableConverter()
 {
     using (var db = new ccEntities())
     {
         var objectset = db.CreateObjectSet <T>();
         this.list = objectset.ToList();
     }
 }
 public EntityKey asdf(T entity)
 {
     using (ccEntities context = new ccEntities())
     {
         var tempset = context.CreateObjectSet <T>();
         tempset.Attach(entity);
         var key = context.ObjectStateManager.GetObjectStateEntry(entity).EntityKey;
         tempset.Detach(entity);
     }
     throw new NotImplementedException();
 }
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="NotSupportedException"></exception>
        /// <param name="id"></param>
        /// <returns></returns>
        public virtual T GetById(int id)
        {
            if (!typeof(T).GetInterfaces().Any(f => f == typeof(IIntIdRecord)))
            {
                throw new NotSupportedException("GetById(int id) is supported only if the Reposytory's type implements IIntIdRecord interface");
            }

            string containerName = _objectContext.DefaultContainerName;
            string setName       = _objectContext.CreateObjectSet <T>().EntitySet.Name;
            // Build entity key
            var entityKey = new EntityKey(containerName + "." + setName, "Id", id);

            return((T)_objectContext.GetObjectByKey(entityKey));
        }
 public TestableObjectSet(ccEntities context)
 {
     _context   = context;
     _objectSet = context.CreateObjectSet <TEntity>();
 }