Entity Framework - Query an Adapter
I'm strugling with entity framework where I've made a library with Business Objects (i.e Account) which are used allover the system.
    
    public class Account
    {
        public long AccountId { get; set; }
        public string AccountText { get; set; }
    }

The entity framework is then converting these forth and back when they are requested or required to save

    public interface EntityAdapter<T> {
        T Materialize(long id);

        long Dematerialize(T business);
        void Dispose(T business);
    }

    public abstract class EFEntityAdapter<T> : EntityAdapter<T> {
        private static MyModel.MyEntities __ctx = null;
        protected MyModel.MyEntities _context
        {
            get
            {
                if (__ctx == null)
                {
                    __ctx = new MyModel.MyEntities ();
                }
                return __ctx;
            }
        }

        public abstract T Materialize(long id);
        public abstract long Dematerialize(T business);
        public abstract void Dispose(T business);
    }
    public class AccountEntityAdapter : EFEntityAdapter<CommonLib.BusinessModels.Account>
    {
        public override CommonLib.BusinessModels.Account Materialize(long id)
        {
            Account entity = (from account in _context.Accounts
                              where account.AccountId == id
                              select account).FirstOrDefault();

            if (entity == null)
                return null;

            CommonLib.BusinessModels.Account business = new CommonLib.BusinessModels.Account();

            business.AccountId = entity.AccountId;
            business.AccountText = entity.AccountText;

            return business;
        }

        public override long Dematerialize(CommonLib.BusinessModels.Account business)
        {
            long id = business.AccountId;

            Account entity = (from account in _context.Accounts
                              where account.AccountId == id
                              select account).FirstOrDefault();

            if (entity == null)
            {
                if (id > 0)
                {
                    throw new Exception("Account with id: " + id + " does not exists");
                }
                else
                {
                    entity = new Account();
                    _context.Accounts.AddObject(entity);
                }
            }

            entity.AccountId = business.AccountId;
            entity.AccountText = business.AccountText;
            _context.SaveChanges();
            business.AccountId = entity.AccountId;
            return entity.AccountId;
        }

        public override void Dispose(CommonLib.BusinessModels.Account business)
        {
            long id = business.AccountId;

            Account entity = (from account in _context.Accounts
                              where account.AccountId == id
                              select account).FirstOrDefault();

            if (entity == null)
            {
                throw new Exception("Account with id: " + id + " was not found, but an attempt to delete it was done");
            }

            _context.DeleteObject(entity);
            _context.SaveChanges();
        }
    }

But now I would like to use the adapter with linq such that I'm able to do something like

    AccountEntityAdapter a = new AccountEntityAdapter();
    List<Commonlib.BusinessModels.Account> list = (from account in a
                                                   where account.AccountId > 6
                                                   select account).ToList();

Such that I'm free of the Entity Context...

How can I achieve this?

Entity Framework - Query an Adapter
===

I'm strugling with entity framework where I've made a library with Business Objects (i.e Account) which are used allover the system.
    
    public class Account
    {
        public long AccountId { get; set; }
        public string AccountText { get; set; }
    }

The entity framework is then converting these forth and back when they are requested or required to save

    public interface EntityAdapter<T> {
        T Materialize(long id);

        long Dematerialize(T business);
        void Dispose(T business);
    }

    public abstract class EFEntityAdapter<T> : EntityAdapter<T> {
        private static MyModel.MyEntities __ctx = null;
        protected MyModel.MyEntities _context
        {
            get
            {
                if (__ctx == null)
                {
                    __ctx = new MyModel.MyEntities ();
                }
                return __ctx;
            }
        }

        public abstract T Materialize(long id);
        public abstract long Dematerialize(T business);
        public abstract void Dispose(T business);
    }
    public class AccountEntityAdapter : EFEntityAdapter<CommonLib.BusinessModels.Account>
    {
        public override CommonLib.BusinessModels.Account Materialize(long id)
        {
            Account entity = (from account in _context.Accounts
                              where account.AccountId == id
                              select account).FirstOrDefault();

            if (entity == null)
                return null;

            CommonLib.BusinessModels.Account business = new CommonLib.BusinessModels.Account();

            business.AccountId = entity.AccountId;
            business.AccountText = entity.AccountText;

            return business;
        }

        public override long Dematerialize(CommonLib.BusinessModels.Account business)
        {
            long id = business.AccountId;

            Account entity = (from account in _context.Accounts
                              where account.AccountId == id
                              select account).FirstOrDefault();

            if (entity == null)
            {
                if (id > 0)
                {
                    throw new Exception("Account with id: " + id + " does not exists");
                }
                else
                {
                    entity = new Account();
                    _context.Accounts.AddObject(entity);
                }
            }

            entity.AccountId = business.AccountId;
            entity.AccountText = business.AccountText;
            _context.SaveChanges();
            business.AccountId = entity.AccountId;
            return entity.AccountId;
        }

        public override void Dispose(CommonLib.BusinessModels.Account business)
        {
            long id = business.AccountId;

            Account entity = (from account in _context.Accounts
                              where account.AccountId == id
                              select account).FirstOrDefault();

            if (entity == null)
            {
                throw new Exception("Account with id: " + id + " was not found, but an attempt to delete it was done");
            }

            _context.DeleteObject(entity);
            _context.SaveChanges();
        }
    }

But now I would like to use the adapter with linq such that I'm able to do something like

    AccountEntityAdapter a = new AccountEntityAdapter();
    List<Commonlib.BusinessModels.Account> list = (from account in a
                                                   where account.AccountId > 6
                                                   select account).ToList();

Such that I'm free of the Entity Context...

How can I achieve this?
