Message 1 of 3
Question about traversing xrecord data
Not applicable
11-21-2013
10:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Spoiler
Spoiler
Hello everybody!
Spoiler
I'm trying to traverse xrecord data of each entity, but I got an error: "Operation is not valid due to the current state of the object.".
Spoiler
Does anyone have idea about this?
I will be grateful to you, if you could write some code about how to solve this.
Best regards,
Spoiler
Here is my code.
Spoiler
if (entity != null)
{
#region XRecord
if (entity.ExtensionDictionary != null && entity.ExtensionDictionary.IsValid)
{
DBDictionary extensionDic = transaction.GetObject(entity.ExtensionDictionary, OpenMode.ForRead) as DBDictionary;
ObjectId rb1 = extensionDic.GetField();
DbDictionaryEnumerator iterator = extensionDic.GetEnumerator();
while (iterator.MoveNext())
{
DBDictionaryEntry dbdEntry = iterator.Current;
Xrecord xr = transaction.GetObject(dbdEntry.Value, OpenMode.ForRead) as Xrecord;
if (xr != null)
{
try
{
ResultBuffer xrrb = xr.Data;
if (xrrb != null)
{
datalog.WriteNormalLog("找到XRECORD!");
int n = 1;
foreach (TypedValue tv in xrrb)
{
datalog.WriteNormalLog("the " + n + "th xrecord: " + tv.Value);
n++;
}
xrrb.Dispose();
}
}
catch (System.Exception ex)
{
ex = null;
}
}
}
}
#endregion
#region XData
ResultBuffer rb = entity.XData;
if (rb != null)
{
int n = 1;
foreach (TypedValue tv in rb)
{
datalog.WriteNormalLog("the " + n + "th xdata: "+ tv.Value);
n++;
}
rb.Dispose();
}
#endregion
}