The last project I worked on was a data importer. Before the import occurs, the existing data in the dwg is checked for duplicates (don't import if that entity exists already). This is accomplished by checking a field in an object data table.
Using a documentlock and a transaction (tr) you can obtain a list of all entities that have object data from the modelspace blocktable record:
// using acapp = Autodesk.AutoCAD.ApplicationServices;
// using acdb = Autodesk.AutoCAD.DatabaseServices;
// reference managedmapapi.dll
// using acgis = Autodesk.Gis.Map;
acapp.Document doc = acapp.Application.DocumentManager.MdiActiveDocument;
acdb.Database db = doc.Database;
using (acapp.DocumentLock docloc = doc.LockDocument())
{
using (acdb.Transaction tr = db.TransactionManager.StartTransaction())
{
acgis.MapApplication mapapp = acgis.HostMapApplicationServices.Application;
acgis.Project.ProjectModel mapprj = mapapp.ActiveProject;
Tables tbls = mapprj.ODTables;
acdb.BlockTable bt = (acdb.BlockTable)tr.GetObject(db.BlockTableId, acdb.OpenMode.ForRead);
acdb.BlockTableRecord mspace = (acdb.BlockTableRecord)tr.GetObject(bt[acdb.BlockTableRecord.ModelSpace], acdb.OpenMode.ForRead);
acgis.ObjectData.Records recs = tbls.GetObjectRecords(0, mspace.ObjectId, acgis.Constants.OpenMode.OpenForRead, false);
acdb.ObjectIdCollection recobjids = new acdb.ObjectIdCollection();
recs.CountObjects(recobjids); // CountObjects returns an objectidcollection
recs.Dispose();
foreach (acdb.ObjectId oid in recobjids)
{
acdb.DBObject fobj = (acdb.DBObject)tr.GetObject(oid, acdb.OpenMode.ForRead);
acgis.ObjectData.Table t = null;
try
{
t = tbls["TABLE NAME"];
acgis.ObjectData.Records objrecs = t.GetObjectTableRecords(0, fobj, acgis.Constants.OpenMode.OpenForRead, false);
if (objrecs.Count > 0)
{
foreach (acgis.ObjectData.Record rec in objrecs)
{
acgis.Utilities.MapValue myval = rec[0]; // the unique id is the first field in the definitions list
flights.Add(myval.StrValue); // add values to a list to be checked when importing
}// foreach record
}// if records are found
objrecs.Dispose();
}// try
catch { } // table doesn't exist
}// foreach object
tr.Commit();
}// using tr
}// using docloc
Other notes:
StringCollection sc = tbls.GetTableNames(); // a list of all object data tables
ADEDEFDATA (autocad command to see object data tables and definitions)
There are other code samples available in this forum but you have to search.
@АлексЮстасу has a link to "odclass-odedit.com" which may do what you require.
@norman.yuan has contributed lots of code (example >>here<< ).
IMHO - it's odd that Autodesk has never produced an FDO driver for their own data (DWG).