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

  • Home
  • SEARCH
  • 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 9213329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:43:17+00:00 2026-06-18T01:43:17+00:00

I am working on an ORM for a Windows CE device. I need to

  • 0

I am working on an ORM for a Windows CE device. I need to cache getter/setter methods of properties as delegates and call them when needed for best perfromance.

Lets say I have 2 entities defined like this:

public class Car
{
    public string Model { get; set; }
    public int HP { get; set; }
}

public class Driver
{
    public string Name { get; set; }
    public DateTime Birthday { get; set; }
}

I need to be able to hold 2 delegates for each property of each entities. So I create a AccessorDelegates class to hold 2 delegates for each property:

 public class AccessorDelegates<T>
{
    public Action<T, object> Setter;
    public Func<T, object> Getter;

    public AccessorDelegates(PropertyInfo propertyInfo)
    {
        MethodInfo getMethod = propertyInfo.GetGetMethod();
        MethodInfo setMethod = propertyInfo.GetSetMethod();

        Setter = BuildSetter(setMethod, propertyInfo); // These methods are helpers
        Getter = BuildGetter(getMethod, propertyInfo); // Can be ignored
    }
}

Now I want to add each AccessorDelegates for a specific entity type into a list. So I defined a class:

public class EntityProperties<T>
{
    public List<AccessorDelegates<T>> Properties { get; set; }
}

I need to hold these EntityProperties for each entity type, in my example Car and Driver. I created a Dictionary<string, EntityProperties<T>> string representing entity name just for simplicity for now:

public class Repo<T>
{
    public Dictionary<string, EntityProperties<T>> EntityPropDict { get; set; }
}

This is where I cannot find a solution to my problem. I want to hold EntityProperties for each entity type but I have to give Repo<T> class a type parameter to be able to create the dictionary (because EntityProperties<T> requires a type parameter).

I need to be able to create it without a type parameter as Repo only. How can I define a Dictionary<string, EntityProperties<T>> without giving my Repo class a type parameter?

  • 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-06-18T01:43:18+00:00Added an answer on June 18, 2026 at 1:43 am

    I’ve come to a solution, a little smart code but works fine.

    I added an interface to be implemented by AccessorDelegates:

    public interface IAccessorDelegates
    {
        void Init(PropertyInfo propertyInfo);
    }
    

    I changed my PropertyMetadata to contain an IAccessorDelegate instead of AccessorDelegate:

    public class PropertyMetadata
    {
        public PropMapAttribute Attribute { get; set; }
        public PropertyInfo PropertyInfo { get; set; }
        public IAccessorDelegates AccessorDelegates { get; set; }
    
        public PropertyMetadata()
        {
    
        }
    
        public PropertyMetadata(PropMapAttribute attribute, PropertyInfo propertyInfo, IAccessorDelegates delegates)
        {
            Attribute = attribute;
            PropertyInfo = propertyInfo;
            AccessorDelegates = delegates;
        }
    
        public AccessorDelegates<T> GetAccesssorDelegates<T>()
        {
            return (AccessorDelegates<T>)AccessorDelegates;
        }
    }
    

    Now, I can create and initialize an AccessorDelegate this way:

     Type accesssorType = typeof(AccessorDelegates<>);
     Type genericAccessorType = accesssorType.MakeGenericType(type);
     IAccessorDelegates accessor = (IAccessorDelegates)Activator.CreateInstance(genericAccessorType);
     accessor.Init(propertyInfo);
    

    PropertyMetadata.GetAccessorDelegates<T>() method enables me to cast and get the object in actual AccessorDelegate<T> type.

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

Sidebar

Related Questions

What is the best/common solution (best practices) to working with relationships in ORM (from
I wanted to compare with best practices when working with an ORM or database
I am working with an ORM that accepts classes as input and I need
I'm working on a backend for an open source Python ORM. The library includes
I've been working with Zend Framework (using Doctrine as the ORM) for quite a
If we have developed our own ORM framework and the framework is working fine
So I'm working on a website with Doctrine as ORM and I get the
Are there any alternatives to the Sequel ORM when working on a Sinatra-based app?
I'm working on a project that uses ADO.NET entity framework as the ORM framework
Right now I'm working on PHP. I am using the Doctrine ORM and the

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.