public bool joinTabletoFeatureLayer(IServerContext mapContext, ITable externalTable, IFeatureLayer featureLayer, string tableJoinField, string layerJoinField, esriJoinType joinType) { IDisplayTable pDispTable = featureLayer as IDisplayTable; IFeatureClass pFCLayer = pDispTable.DisplayTable as IFeatureClass; ITable pTLayer = (ITable)pFCLayer; string strJnFieldLayer = layerJoinField; string strJnFieldTable = tableJoinField; IMemoryRelationshipClassFactory pMemRelFact = (IMemoryRelationshipClassFactory)mapContext.CreateObject("esriGeoDatabase.MemoryRelationshipClassFactory"); IRelationshipClass pRelClass = (IRelationshipClass)pMemRelFact.Open("Join", (IObjectClass)externalTable, strJnFieldTable, (IObjectClass)pTLayer, strJnFieldLayer, "forward", "backward", esriRelCardinality.esriRelCardinalityOneToOne); IDisplayRelationshipClass pDispRC = (IDisplayRelationshipClass)featureLayer; pDispRC.DisplayRelationshipClass(pRelClass, joinType); //esriLeftOuterJoin IDisplayTable dt = (IDisplayTable)featureLayer; ITable jointable = dt.DisplayTable; bool retval = false; if (jointable is IRelQueryTable) { retval = true; } return retval; }
private void btnOK_Click(object sender, EventArgs e) { if (this.radioGroup1.SelectedIndex == 0) { this.esriJoinType_0 = esriJoinType.esriLeftOuterJoin; } else { this.esriJoinType_0 = esriJoinType.esriLeftInnerJoin; } }
private void btnJoiningType_Click(object sender, EventArgs e) { frmJoinTypeSet set = new frmJoinTypeSet { JoinType = this.esriJoinType_0 }; if (set.ShowDialog() == DialogResult.OK) { this.esriJoinType_0 = set.JoinType; } }
/// <summary> /// Sets a join based on the specified relationship class and join type. /// </summary> /// <param name="source">The source.</param> /// <param name="foreignClass">The join.</param> /// <param name="layerKeyField">Name of the layer field.</param> /// <param name="foreignKeyField">Name of the join field.</param> /// <param name="cardinality">The cardinality.</param> /// <param name="joinType">Type of the join.</param> /// <returns> /// Returns a <see cref="IRelQueryTable" /> represents the table and feature join. /// </returns> public static IRelQueryTable Add(this IFeatureLayer source, IObjectClass foreignClass, string layerKeyField, string foreignKeyField, esriRelCardinality cardinality, esriJoinType joinType) { IRelQueryTable result; IRelationshipClass relClass; var table = ((IDisplayTable)source).DisplayTable as IRelQueryTable; if (table != null) { result = source.Add(table, foreignClass, string.Format("{0}.{1}", ((IDataset)source.FeatureClass).Name, layerKeyField), foreignKeyField, cardinality, joinType); relClass = result.RelationshipClass; } else { var layer = (IFeatureClass)((IDisplayTable)source).DisplayTable; relClass = layer.Join(foreignClass, layerKeyField, foreignKeyField, cardinality, null); var factory = new RelQueryTableFactoryClass(); result = factory.Open(relClass, true, null, null, "", true, joinType == esriJoinType.esriLeftInnerJoin); } IDisplayRelationshipClass display = (IDisplayRelationshipClass)source; display.DisplayRelationshipClass(relClass, joinType); return(result); }
/// <summary> /// Sets a join based on the specified relationship class and join type. /// </summary> /// <param name="source">The source.</param> /// <param name="table">The table.</param> /// <param name="foreignClass">The join.</param> /// <param name="layerKeyField">Name of the layer field.</param> /// <param name="foreignKeyField">Name of the join field.</param> /// <param name="cardinality">The cardinality.</param> /// <param name="joinType">Type of the join.</param> /// <returns> /// Returns a <see cref="IRelQueryTable" /> represents the table and feature join. /// </returns> public static IRelQueryTable Add(this IFeatureLayer source, IRelQueryTable table, IObjectClass foreignClass, string layerKeyField, string foreignKeyField, esriRelCardinality cardinality, esriJoinType joinType) { if (source != null) { var factory = new RelQueryTableFactoryClass(); var origin = factory.Open(table.RelationshipClass, true, null, null, "", true, ((IRelQueryTableInfo)table).JoinType == esriJoinType.esriLeftInnerJoin); var join = ((IObjectClass)origin).Join(foreignClass, string.Format("{0}.{1}", ((IDataset)table.SourceTable).Name, layerKeyField), foreignKeyField, cardinality, null); var result = factory.Open(join, true, null, null, "", true, joinType == esriJoinType.esriLeftInnerJoin); IDisplayRelationshipClass display = (IDisplayRelationshipClass)source; display.DisplayRelationshipClass(result.RelationshipClass, joinType); return(result); } return(null); }
void IDisplayRelationshipClass.DisplayRelationshipClass(IRelationshipClass relClass, esriJoinType JoinType) { ((IDisplayRelationshipClass)featureLayer).DisplayRelationshipClass(relClass, JoinType); }
private void btnOk_Click(object sender, EventArgs e) { _indexLayer = 0; _breakCount = int.Parse(txtBreakCount.EditValue.ToString()); _maxValue = double.Parse(txtMax.EditValue.ToString()); _minValue = double.Parse(txtMin.EditValue.ToString()); _thuaName = DataNameTemplate.Thua_Gia_Dat; int intloaidat = cbxLoaiDat.SelectedIndex; string strLoaiDat = ""; string tblGiaDat = ""; switch (intloaidat) { case 0: tblGiaDat =DataNameTemplate.Thua_Gia_Dat; //strLoaiDat = "Đất nông nghiệp"; break; case 1: tblGiaDat = DataNameTemplate.Thua_Gia_Dat; strLoaiDat = "Đất phi nông nghiệp tại đô thị"; break; case 2: tblGiaDat = DataNameTemplate.Thua_Gia_Dat; strLoaiDat = "Đất phi nông nghiệp tại nông thôn"; break; default: tblGiaDat = DataNameTemplate.Thua_Gia_Dat; strLoaiDat = "Đất nông nghiệp"; break; } _giadatName = string.Format("{0}_{1}",tblGiaDat,spnNam.EditValue); int fieldName = cbxField.SelectedIndex; switch (fieldName) { case 0: _fieldName = string.Format("{0}.{1}", _giadatName, "giadat"); break; case 1: _fieldName = string.Format("{0}.{1}", _giadatName, "dongia"); break; default: _fieldName = string.Format("{0}.{1}", _giadatName, "dongia"); break; } SdeConnection conn = new SdeConnection(); ISdeConnectionInfo sdeConn = (ISdeConnectionInfo)conn; IFeatureWorkspace fw = (IFeatureWorkspace)sdeConn.Workspace; //ITable giadatTable = fw.OpenTable(_giadatName); _giadatLayer=new FeatureLayerClass(); string tgdName = string.Format("{0}_{1}", DataNameTemplate.Thua_Gia_Dat, spnNam.EditValue); _giadatLayer.FeatureClass = fw.OpenFeatureClass(tgdName); _giadatLayer.Name = string.Format("{0} năm {1}", "Giá đất", spnNam.EditValue); //IFeatureLayer flThua = (IFeatureLayer)_mapControl.get_Layer(_indexLayer); _joinFieldOnLayer = "mathua"; _joinFieldOnTable = "mathua"; //_layer4Join = flThua; //_table4Join = giadatTable; int joinType = cbxType.SelectedIndex; switch (joinType) { case 0: _type = esriJoinType.esriLeftInnerJoin; break; case 1: _type = esriJoinType.esriLeftOuterJoin; break; default: _type = esriJoinType.esriLeftInnerJoin; break; } _cardinality = esriRelCardinality.esriRelCardinalityOneToMany; _controller = new ThematicController(_thematic, this); _controller.SingleRender() ; closeParent(); }