Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6243985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:14:34+00:00 2026-05-24T12:14:34+00:00

Possible Duplicate: EF4 Cast DynamicProxies to underlying object I’m trying to figure out how

  • 0

Possible Duplicate:
EF4 Cast DynamicProxies to underlying object

I’m trying to figure out how to clone or convert a System.Data.Entity.DynamicProxies into it’s actual class. Eg:

System.Data.Entity.DynamicProxies.Currency_F4008E27DE_etc is the proxy class
MyApp.Entities.Currency is the real class

All of the classes in MyApp.Entities inherit from BaseEntity, so I tried to do the converting there:

public abstract partial class BaseEntity
{
    public T ShallowCopy<T>() where T : BaseEntity
    {
        return this.MemberwiseClone() as T;
    }
    // other BaseEntity properties not relevent here
}

And then converting the DynamicProxies into the real class:

// this returns a DynamicProxies class
Currency currency = LookupDefaultCurrency(); 
// this one needs to return a Entities.Currency class 
// (but currently returns a DynamicProxies class too
Currency pocoCurrency = (Currency)currency.ShallowCopy<Currency>();
HttpRuntime.Cache[key] = pocoCurrency;

The reason for this is that I want to remove all Entity Framework tracking and etc from this object and just store its plain (POCO) properties in the cache. And I will need to be able to do this for all 100 or so Entity classes, so it has to be reasonably generic – without manually saying object1.foo = object2.foo for every single property.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:14:35+00:00Added an answer on May 24, 2026 at 12:14 pm

    Maybe this article is helpful. It discusses several methods for cloning data. I’m not sure if these methods can be used to convert an object of type A to an object of type B. But it’s definitely worth a try.

    I would be very interested in the outcome of this, since this NuGet package also uses the generic repository pattern and memcached to address the same caching technique and your problem seems to be same there when deserializing data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Learning to write a compiler I looked around trying to find out
Possible Duplicate: Where is EntityConfiguration in EF4 VS 2010 RTM? I apologize if this
Possible Duplicate: Entity Framework with NOLOCK I'm using EF4 and .Net 4 to load
Possible Duplicate: Can you write object oriented code in C? Hi, can someone point
Possible Duplicate: Reading through file using ifstream I'm trying to find a way to
Possible Duplicate: C++ convert int and string to char* Hello, i am making a
Possible Duplicate: Find out the instance id from within an ec2 machine I am
Possible Duplicate: EF4 cross database relationships Is it possible to have 3 databases: Shared
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
Possible Duplicate: XPath: How to match attributes that contain a certain string I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.