public void It_wraps_poco_in_adapter()
        {
            var obj        = new ClrPoco();
            var entityType = CreateModel().GetEntityType(typeof(ClrPoco));
            var entry      = _factory.Create(entityType, obj);
            var adapter    = new StateEntryTableEntityAdapter <ClrPoco>(entry);

            Assert.Same(obj, adapter.Entity);
        }
        public virtual object GetEntity(IEntityType entityType, IValueReader valueReader)
        {
            Check.NotNull(entityType, "entityType");
            Check.NotNull(valueReader, "valueReader");

            var keyProperties = entityType.GetPrimaryKey().Properties;

            var entityKey
                = _entityKeyFactorySource
                  .GetKeyFactory(keyProperties)
                  .Create(entityType, keyProperties, valueReader);

            var stateEntry = _stateManager.TryGetEntry(entityKey);

            if (stateEntry == null &&
                !_stateEntriesByEntityKey.TryGetValue(entityKey, out stateEntry))
            {
                stateEntry = _stateEntryFactory.Create(entityType, valueReader);

                _stateEntriesByEntityKey.Add(entityKey, stateEntry);
                _stateEntriesByEntityInstance.Add(stateEntry.Entity, stateEntry);
            }

            return(stateEntry.Entity);
        }