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 8883791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:54:06+00:00 2026-06-14T20:54:06+00:00

I have this code that I am currently adapting to use nested entity (entity

  • 0

I have this code that I am currently adapting to use nested entity (entity framework). I have an entity which contains 2 property which are 2 children entities.

The first step was to read the metadata on both classes, starting from the first classes, building up a list of properties. This is completed. Now I need to iterate over my object to find the good property to do the DataBinding.

This is what I currently have :

variables example :

datasource = namespace.A
propriete = {System.Nullable`1[System.Int32] count} 
propriete.DeclaringType {Name = "prop2" FullName = "Namespace.Metadata.prop2"}

code :

if (this.datasource != null)
{
    var y = (T)this.datasource;

    var propList = typeof(T).GetProperties();
    if (propList.ToList().Contains(propriete))
    {
        TextBox.Text = DataBinder.Eval(y, propriete.Name).ToString();
    }
    else
    {
        TextBox.Text = ":( need child-support!";
    }
}

My main problem is that my object type is unknown till runtime (Type T) so I have no idea on how to find my field.

Quick model :

Class A {
  public B prop1;
  public C prop2;
}

Class B {
   int count;
   string name;
}

Class C {
   int count;
   string name;
}

A.prop1.count = 1;
A.prop1.name = "a";
A.prop2.count = 2;
A.prop2.name = "b";

Right now, my property name are all unique (more specific than count/name), but I expect them to be the same (count/name) at some point.

propriete will probably have to “filter” with DeclaringType/ReflectedType for non-unique name.

A brute-force solution considering unique name, although not elegant, might be accepted.

Extra problem : propriete use another partial class contains in the metadata namespace while datasource use the main class.

(… And if you are curious as to what this system does : It builds a html table (with .net controls) based on an entity based on this metadata.entity dataAttribute.)

  • 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-14T20:54:07+00:00Added an answer on June 14, 2026 at 8:54 pm

    Here’s what I ended up with :

    if (this.datasource != null)
    {
        var y = (T)this.datasource;
    
        var propList = typeof(T).GetProperties();
        //try to assign the prop but it might be on a child-prop.
        try 
        {           
            retour = DataBinder.Eval(y, propriete.Name).ToString();
        }
        catch 
        {
            foreach (PropertyInfo prop in propList)
            {
                if ((prop.PropertyType).FullName.Contains("Env."))
                {
                    var childPropList = prop.PropertyType.GetProperties();
                    foreach (PropertyInfo childProp in childPropList)
                    {
                        if (((System.Reflection.MemberInfo)(childProp)).Name == propriete.Name)
                        {
                            var x = DataBinder.GetPropertyValue(y, prop.Name);
                            retour = DataBinder.Eval(x, propriete.Name).ToString();
                        }
                    }
                }
            }
        }
    }
    

    For now it works, but it might not be versatile enough in a near future.

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

Sidebar

Related Questions

I have an Entity in Code First Entity framework that currently looks like this:
I currently have this useful code that I found elsewhere on StackOverflow: form.DrawToBitmap(bmp, new
I have this code that where I would normally use one line: if (tableView
I currently have this code that parses imdbAPI http returns: text = 'unicode: {Title:The
Currently I have this code that works fine [UIView setAnimationDidStopSelector:@selector(animationDone:finished:context:)]; - (void)animationDone:(NSString *)animationID finished:(BOOL)finished
I currently have this code that creates 4 tabs using tabactivity: public class toknapp
I currently have this code that works. I have two questions. How do I
I have this piece of code that currently almost does what I need. It
Currently I have this code that changes the default background in a TableView to
I currently have this code use for printing a table in mysql database ,

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.