转自:
1、插入
1 2 3 ///4 5 ///向featureclass中批量插入features ,批量插入features,用buffer的方法,要比循环一个个Store的方法快 6 7 /// 8 9 /// 操作数据所在的IFeatureClass10 11 private void InsertFeatures( IFeatureClass pFeatureClass , List< IGeometry> pGeos )12 13 {14 15 IFeatureBuffer pFeatBuf = pFeatureClass.CreateFeatureBuffer();16 17 IFeature pFeat = pFeatBuf;18 19 IFeatureCursor pFeatCur= pFeatureClass.Insert(true);20 21 for(int i = 0 ;i< pGeos.Count ;i++)22 23 {24 25 pFeat.Shape = pGeos(i);26 27 pFeatCur.InsertFeature(pFeatBuf);28 29 //避免一次flush,导致速度过慢30 31 if (i Mod 100 == 0 )32 33 {34 35 pFeatCur.Flush()36 37 }38 39 pFeatCur.Flush()40 41 }
2.删除
1 ///删除某featurelayer中所有feature 2 3 /// 该方法可以给一个queryfilter,进行删除符合条件的Ifeatures/// 4 5 /// :操作的图层 6 7 Private void DeleteAllFeatures(IFeatureLayer pLayer ) 8 9 {10 11 ITable pTable = pLayer.FeatureClass;12 13 pTable.DeleteSearchedRows(null);14 15 }
------------------------------------------------------ 补充分割线 ------------------------------------------------------
还有更效率的方法: