Is there a way to fake an id column in NHibernate?

Let's say I map a simple object to a table containing duplicate records, and I want to allow duplicates in my code. I do not need to update / insert / delete in this table, only show records.

Is there a way I can put a fake (generated) identifier column in the mapping file to trick NHibernate into thinking that the rows are unique? Creating a composite key will not work because there may be duplicates in all columns.

If this is not possible, what is the best way around this problem?

Thank!

Edit: request seemed to be a way

+3
source share
2 answers

NHibernate , , , - .

, ( SQL Server - ), - .

, , , () RowNumber, . ( ) .

, , SQL- . IIRC, NHibernate SQL- , " " .

+2

, , newguid(),

SELECT NEWGUID() ID, * FROM TABLE

. , . .

0

Source: https://habr.com/ru/post/1699072/


All Articles