1

I've come across a case, we're I've a column mapped twice (un-beknown to us..), and now updates are throwing the "Parameter +1 doesn't exist error".

Is there any suitable way we can achieve the following mapping?

(Please note, this is an inherited database...)

        References(x => x.Matter).Columns(new[] { "c_client", "c_matter" }).NotFound.Ignore();
        References(x => x.Client).Column("c_client");
Stuart.Sklinar
  • 3,683
  • 4
  • 35
  • 89

2 Answers2

3

An option for you could be to mark the Client column as read only.

References(x => x.Matter).Columns(new[] { "c_client", "c_matter" }).NotFound.Ignore();
References(x => x.Client).Column("c_client").ReadOnly();

This should make it so NHiberante does not try to update it

Vadim
  • 17,897
  • 4
  • 38
  • 62
  • Thanks for this - I'll keep it it mind for the future - however, I'll stick with all refreactoring, and DTO's (as they'd have happened anyway!) +1 – Stuart.Sklinar Jun 11 '12 at 14:56
1

This is an invalid mapping. You can't use the same column twice.

My suggestion is that you map c_matter and c_client as scalar properties and use queries to retrieve the corresponding matters and clients.

Diego Mijelshon
  • 52,548
  • 16
  • 116
  • 154
  • That is the answer I should have thought of! – Stuart.Sklinar Jun 11 '12 at 08:04
  • Actually - on that thought, any suggestions on how I could get a IRepository down to my entity layer? – Stuart.Sklinar Jun 11 '12 at 08:11
  • The least obtrusive is passing it. `theEntity.GetMatter(repository)` – Diego Mijelshon Jun 11 '12 at 10:00
  • Good idea..! I took it out of there completely, and kept anything to do with Clients into a client Services class - as it required the extra query to get it anyway. I also added DTO for times when it is required to be returned from the DTO, and thus not really accessed via the main object anyway.. (Just took a day of refractoring/fixing tests..) – Stuart.Sklinar Jun 11 '12 at 14:13