public void Delete(string entitySetName, object entityObject)
        {
            CheckNotReadOnly();

            CustomEntitySet entitySet = GetEntitySetByName(entitySetName);

            entitySet.Remove(entityObject);
        }
        public IQueryable CreateQuery(string entitySetName)
        {
            CustomUtils.CheckArgumentNotNull(entitySetName, "entitySetName");

            CustomEntitySet entitySet = GetEntitySetByName(entitySetName);

            Debug.Assert(null != entitySet);
            Debug.Assert(entitySet is IEnumerable);

            return(((IEnumerable)entitySet).AsQueryable());
        }
        public IQueryable <EntityObjectType> CreateQueryOfT <EntityObjectType>(string entitySetName)
        {
            CustomUtils.CheckArgumentNotNull(entitySetName, "entitySetName");

            CustomEntitySetType entitySetType = _metadata.GetEntitySet(entitySetName);
            CustomEntityType    entityType    = _metadata.GetEntityType(typeof(EntityObjectType));

            if (!entitySetType.BaseElementType.IsAssignableFrom(entityType))
            {
                throw new InvalidOperationException(String.Format(
                                                        "The base element type '{0}' of the entity set '{1}' is not compatible with " +
                                                        "the queried entity type '{2}'.",
                                                        entitySetType.BaseElementType, entitySetName, entityType
                                                        ));
            }

            CustomEntitySet entitySet = GetEntitySetByName(entitySetName);

            Debug.Assert(null != entitySet);
            Debug.Assert(typeof(IEnumerable <EntityObjectType>).IsAssignableFrom(entitySet.GetType()));

            return(((IEnumerable <EntityObjectType>)entitySet).AsQueryable());
        }