public async Task JoiningFileGeodatabaseFeatureClassToOracleQueryLayer()
{
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri("C:\\Data\\LocalGovernment.gdb"))))
using (Database database = new Database(new DatabaseConnectionProperties(EnterpriseDatabaseType.Oracle)
{
AuthenticationMode = AuthenticationMode.DBMS,
Instance = "instance",
User = "user",
Password = "password",
Database = "database"
}))
using (FeatureClass leftFeatureClass = geodatabase.OpenDataset<FeatureClass>("Hospital"))
using (Table rightTable = database.OpenTable(database.GetQueryDescription("FacilitySite")))
{
Field originPrimaryKey = leftFeatureClass.GetDefinition().GetFields().FirstOrDefault(field => field.Name.Equals("facilityId"));
Field destinationForeignKey = rightTable.GetDefinition().GetFields().FirstOrDefault(field => field.Name.Equals("hospitalID"));
VirtualRelationshipClassDescription description = new VirtualRelationshipClassDescription(
originPrimaryKey, destinationForeignKey, RelationshipCardinality.OneToOne);
using (RelationshipClass relationshipClass = leftFeatureClass.RelateTo(rightTable, description))
{
JoinDescription joinDescription = new JoinDescription(relationshipClass)
{
JoinDirection = JoinDirection.Forward,
JoinType = JoinType.LeftOuterJoin
};
Join join = new Join(joinDescription);
using (Table joinedTable = join.GetJoinedTable())
{
// Perform operation on joined table.
}
}
}
});
}