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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:40:03+00:00 2026-06-06T23:40:03+00:00

When creating a new item; is there any way to access all the field

  • 0

When creating a new item; is there any way to access all the field values that are set.

Since I’m using Entity.GetModifiedMembers() method to access the values of the fields that are changed when updating for logging purposes, the purpose is to have the equivalent result through an entity when creating, like a method Entity.GetSetMembers().

So in general, all I need is a key-value pair with “member name” and “value” items.

Example:

public class SomethingEntity
{
    public int Id {get;set;}
    public string Name {get;set;}
    public DateTime Created {get;set;}
    public DateTime Modified {get;set;}
}

public Dictionary<string, string> GetFieldsAndValuesOfCreatedItem(object entity)
{
    //This is what I need, that can take all the objects from an entity and give
    //the property-value pairs for the object instance
    return RequieredMethod(entity);
}

public ExampleMethod()
{
    var newObject = new SomethingEntity() { Name = "SomeName", Created = DateTime.Now };
    Entity.insetOnSubmit(newObject);
    Entity.SubmitChanges();

    var resultList = GetFieldsAndValuesOfCreatedItem(newObject);

    foreach (var propertyKeyValue in resultList)
    {
        var propertyString = "Property Name: " + propertyKeyValue.Key;
        var valueString = "Value : " + propertyKeyValue.Value; 
    }
}
  • 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-06T23:40:04+00:00Added an answer on June 6, 2026 at 11:40 pm

    I’ve found out that, Reflection is the answer for that as far as I could find: so here is the method I’ve come up with:

    public static Dictionary<string, string> GetFieldsAndValuesOfCreatedItem(object item)
    {
        var propertyInfoList = item.GetType().GetProperties(BindingFlags.DeclaredOnly |
                                                                BindingFlags.Public |
                                                                BindingFlags.Instance);
    
        var list = new Dictionary<string, string>();
    
        foreach (var propertyInfo in propertyInfoList)
        {
            var valueObject = propertyInfo.GetValue(item, null);
            var value = valueObject != null ? valueObject.ToString() : string.Empty;
    
            if (!string.IsNullOrEmpty(value))
            {
                list.Add(propertyInfo.Name, value);
            }
        }
    
        return list;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When creating a new item - Web Form using Master Page I get a
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
When creating a new WSPBuilder project or new WSPBuilder item in Visual Studio, you
I am new to creating work item types in TFS and want to create
I'm creating new Site Definitions using this method: http://weblogs.asp.net/paulballard/archive/2007/04/09/creating-a-custom-sharepoint-2007-portal-site-definition-using-the-portalprovisioningprovider-class.aspx and when they get created,
I am creating a new ExtJS widget using Ext.view.View. The template for this view
Is there a way to suppress model validation in Backbone.js when a new model
I'm creating a java Swing app and I'm new to that. The problem is
when i am creating new android project from visual studio 2010 it gives the
When I'm creating new project with GWT plug in it creates a skeleton project

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.