Search code examples
c#asp.netdevexpressxpo

Find Primary Key From Persistent Class in Devexpress


I have Added Persistent Class in in my webapplication. It contains 20 classes..,

In my Default.aspx.cs, I want to get list of Primary key name from all classes in Persistent class.. How can i find it?


Solution

  • I assumed that you use XPO:

    foreach (XPClassInfo classInfo in xpoSession.Dictionary.Classes)
    {
        Console.WriteLine(classInfo.FullName + "=" + classInfo.KeyProperty);
    }
    

    If you have simple primary key, use classInfo.KeyProperty.Name to fetch its name.