How do I Insert or Update (or overwrite) a record using NHibernate?

后端 未结 6 1535
忘掉有多难
忘掉有多难 2021-02-02 00:51

I need to write a row to the database regardless of whether it already exists or not. Before using NHibernate this was done with a stored procedure. The procedure would attempt

6条回答
  •  死守一世寂寞
    2021-02-02 01:27

    Query objects where keyword = x, take FirstOrDefault. If it's null, Add new object, if it exists, update object that you got and call saveOrUpdate on it.

提交回复
热议问题