简体   繁体   中英

NHibernate Fluent Sqlite force to use “Insert or Replace”

I need to force for NHibernate to not use typical INSERT statment, but sqlite's INSERT OR REPLACE statement

I know that it is possible when in ClassMap<> I'll use SqlInsert("INSERT OR REPLACE...") , but I have more then 100 entities and I don't wont to add it for every mapping class.

Has anyone an idea how to do it in another simple way?

INSERT OR REPLACE needs the information which column is unique and decides if insert or replace should be used. There is no builtin mechanism for this in NHibernate because it is too special. The easiest way is to query before saving or handling the Duplicate key Exception (ISqlExceptionConverter helps here)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM