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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:45:54+00:00 2026-06-02T00:45:54+00:00

I have a base class called BaseEvent and several descendants classes: public class BaseEvent

  • 0

I have a base class called BaseEvent and several descendants classes:

public class BaseEvent {
    // the some properties
    // ...
}

[MapInheritance(MapInheritanceType.ParentTable)]
public class Film : BaseEvent {
   // the some properties
   // ...
}
[MapInheritance(MapInheritanceType.ParentTable)]
public class Concert : BaseEvent {
    // the some properties
    // ...
}

I have a code which create the BaseEvent instance at runtime:

BaseEvent event = new BaseEvent();
// assign values for a properties
// ...    
baseEvent.XPObjectType = Database.XPObjectTypes.SingleOrDefault(
    t => t.TypeName == "MyApp.Module.BO.Events.BaseEvent");

Now, this event will be shows in BaseEvent list view.

I want to do the following: when a user click Edit button then show in list view lookup field with all descendants types. And when user saves record change ObjectType to selected value.

How can I do this?
Thanks.

PS. this is asp.net app.

  • 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-02T00:45:56+00:00Added an answer on June 2, 2026 at 12:45 am

    I’m not sure that your approach is correct for what you are trying to achieve. First, I’ll answer the question you have asked, and afterwards I’ll try to explain how the XAF already provides the functionality you are trying to achieve, namely how to choose which subclass of record to create from the user interface.

    In order to create a property which allows the user to choose a Type within the application, you can declare a TypeConverter:

    public class EventClassInfoTypeConverter : LocalizedClassInfoTypeConverter
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            List<Type> values = new List<Type>();
            foreach (ITypeInfo info in XafTypesInfo.Instance.PersistentTypes)
            {
                if ((info.IsVisible && info.IsPersistent) && (info.Type != null))
                {
                    // select BaseEvent subclasses
                    if (info.Type.IsSubclassOf(typeof(BaseEvent))) 
                        values.Add(info.Type);
                }
            }
            values.Sort(this);
            values.Insert(0, null);
            return new TypeConverter.StandardValuesCollection(values);
        }
    }
    

    And then your base event class would look like:

    public class BaseEvent: XPObject
    {
        public BaseEvent(Session session)
            : base(session)
        { }
    
        private Type _EventType;
        [TypeConverter(typeof(EventClassInfoTypeConverter))]
        public Type EventType
        {
            get
            {
                return _EventType;
            }
            set
            {
                SetPropertyValue("EventType", ref _EventType, value);
            }
        }
    }
    

    However, I suspect this is not the functionality you require. Modifying the value of the property will NOT change the base type of the record. That is, you will end up with a record of type BaseEvent which has a property Type equal to ‘Concert’ or ‘Film’.

    XAF already provides a mechanism for selecting the type of record to create. In your scenario, you will find that the New button is a dropdown with your different subclasses as options:

    enter image description here

    Therefore you do not need to create a ‘type’ property within your object. If you need a column to show the type of event in the list view, you can declare a property as follows

    [PersistentAlias("XPObjectType.Name")]
    public string EventType
    {
        get
        {
            return base.ClassInfo.ClassType.Name;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a base class called BaseEvent . And, 3 classes derived from BaseEvent
I have a base-class called Element. Some other classes (like Label and Image) both
I have a base class called Items and 3 derived classes, and within the
I have an abstract base class called Curve . There are three classes that
I have a class called Prescriptions. It has properties that are other classes. So,
I have three different base classes: class BaseA { public: virtual int foo() =
I have a base class called Component which has a number of classes derived
I have a base class called Mijloc_transport and 2 derived classes called Masina and
If I have a polymorphic base class called Base as well as classes Derived1
I have a base class called Component. I also have 2 interfaces I2DComponent, and

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.