Performing Insert OR Update (upsert) on sql server compact edition

后端 未结 7 1726
陌清茗
陌清茗 2020-12-17 06:36

I have c# project that is using sqlserver compact edition and entity framework for data access. I have the need to insert or update a large amount of rows, 5000+ or more to

7条回答
  •  清酒与你
    2020-12-17 07:24

    See SqlCeResultSet. For a .NETCF project I removed almost all sql code in favor of this class. Just search for "SqlCeResultSet" here and msdn.

    A quick overview:

    1. Open the resultSet. If you need seek (for existence check) you will have to provide an index for the result set.

    2. Seek on the result set & read to check whether you found the row. This is extremely fast even on tables with tens of thousands rows (because the seek uses the index).

    3. Insert or update the record (see SqlCeResultSet.NewRecord).


    We have successfully developed a project with a sqlce database with a main product table with over 65000 rows (read/write with 4 indexes).

提交回复
热议问题