ArcEngine資料刪除幾種方法和效能比較

2022-03-23 19:44:52 字數 2611 閱讀 6857

**原文 arcengine資料刪除幾種方法和效能比較

一、幾種刪除方法**

1.查詢結果中刪除

private void delete1(ifeatureclass pfeatureclass)

iqueryfilter pqueryfilter = new queryfilterclass();

pqueryfilter.whereclause = "objectid<=" + deletenum;

ifeaturecursor pfeaturecursor = pfeatureclass.search(pqueryfilter, false);ifeature pfeature = pfeaturecursor.nextfeature();

while (pfeature != null)

pfeature.delete();

pfeature = pfeaturecursor.nextfeature();

system.runtime.interopservices.marshal.releasecomobject(pqueryfilter);

2.更新游標刪除

private void delete2(ifeatureclass pfeatureclass)

iqueryfilter pqueryfilter = new queryfilterclass();

pqueryfilter.whereclause = "objectid<=" + deletenum;

ifeaturecursor pfeaturecursor = pfeatureclass.update(pqueryfilter, false);

ifeature pfeature = pfeaturecursor.nextfeature();

while (pfeature != null)

pfeaturecursor.deletefeature();

pfeature = pfeaturecursor.nextfeature();

system.runtime.interopservices.marshal.releasecomobject(pqueryfilter);

3.使用deletesearchedrows刪除

private void delete4(ifeatureclass pfeatureclass)

iqueryfilter pqueryfilter = new queryfilterclass();

pqueryfilter.whereclause = "objectid<=" + deletenum;

itable ptable = pfeatureclass as itable;

ptable.deletesearchedrows(pqueryfilter);

system.runtime.interopservices.marshal.releasecomobject(pqueryfilter);

4.executesql刪除

private void delete4(ifeatureclass pfeatureclass)

idataset pdataset = pfeatureclass as idataset;

pdataset.workspace.executesql("delete from " + pfeatureclass.aliasname + " where objectid<=" + deletenum);

二、測試效能和比較

1相同的資料條件,刪除2000條記錄

2測試**

ifeaturelayer pfeaturelayer = axmapcontrol1.map.get_layer(0) as ifeaturelayer;

ifeatureclass pfeatureclass = pfeaturelayer.featureclass;

system.diagnostics.stopwatch mywatch = new system.diagnostics.stopwatch();

mywatch.start();

delete1(pfeatureclass)

//delete2(pfeatureclass);

//delete3(pfeatureclass);

//delete4(pfeatureclass);

ArcEngine資料刪除幾種方法

一 幾種刪除方法 1.查詢結果中刪除 private void delete1 ifeatureclass pfeatureclass system.runtime.interopservices.marshal.releasecomobject pqueryfilter 2.更新游標刪除 priv...

ArcEngine 幾種刪除資料的比較

1 ifeaturecursor 游標查詢後,遍歷刪除 2 更新游標刪除ifeaturecursor.deletefeature 3 itable.deletesearchedrows刪除 4 idataset.workspace.executesql 一 幾種刪除方法 1.查詢結果中刪除 priv...

ArcEngine資料刪除幾種方法和效能比較

原文 arcengine資料刪除幾種方法和效能比較 一 幾種刪除方法 1.查詢結果中刪除 private void delete1 ifeatureclass pfeatureclass iqueryfilter pqueryfilter new queryfilterclass pqueryfil...