Saturday, 15 August 2015

c# - Why is NPoco ignoring column and property names and mapping almost randomly? -



c# - Why is NPoco ignoring column and property names and mapping almost randomly? -

i'm using npoco orm (a branch of petapoco) i've noticed it's mapping columns incorrectly in cases.

i'm using stored procedure , poco property names identical column names produced stored procedure:

string sql = "exec api_getvenuesummarybyid @@venueid = @venueid"; var venue = db.firstordefault<venuesummary>(sql, new { venueid = venueid });

the stored procedure simple select statement couple of variables included (removing them doesn't help):

declare @hasoffers bit if exists(select * offers dbo.offers.entrytype='v' , offers.entryid = @venueid , getdate() <= validtodate) set @hasoffers = 1 select venue.venueid, venuename, town, county, country, packagecode, meetingroomsno, maxmeetingcapacity, bedroomsno, metadescription shortdescription, 'dummyresult.jpg' primaryimagefilename, @hasoffers hasspecialoffers, cast(timestamp bigint) recordversion dbo.venue venue.venueid = @venueid

is there function in npoco causes guess mappings (ignoring names)? if so, how can disable , forcefulness match based on column , property names?

currently work around seems to utilize column attribute <-- doesn't work either

at moment, auto-formatting stored procedure (or alter results in alter of column order) breaking application.

edit 2

i've noticed if restart website application (eg editing web.config or updating application code) column order fixes itself. can assume problem related npoco internally caching column indexes - , if indexes change, mappings incorrect. i'm not sure if there's mechanism clear cache that's perhaps not working?

this problem how npoco (and petapoco) caches codegen used map sql statement poco.

usually isn't problem if changing code when changing sql cache rebuild, if create poco first start alter sp after first initial run mappings incorrect.

this issues has been fixed in 2.5.83-beta, , @ column names , positions determine cache key.

thanks help @nickg

c# petapoco micro-orm npoco

No comments:

Post a Comment