Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation to reflect use of UpdateUsing #24

Open
KeishaW opened this issue Apr 22, 2020 · 1 comment
Open

Update documentation to reflect use of UpdateUsing #24

KeishaW opened this issue Apr 22, 2020 · 1 comment

Comments

@KeishaW
Copy link

KeishaW commented Apr 22, 2020

I was attempting to do an update as described in the docs:

var db = new MightyOrm(connectionString, "Person",  "PersonID");
var p = db.Single(42); // get from Person table by primary key
p.LoyalCustomer = true;
db.Update(p);

But I got this error: Cannot complete UPDATE operation, you must provide a WHERE value (specify 1=1 to affect all rows)

Looking at the Update methods, there seems to be no parameter for where .

Digging further into the Issues here lead me to this closed issue about UpdateUsing which seems to work.

Could the documentation be updated to specify using UpdateUsing instead of just Update as this does not seem to work?

@mikebeaton
Copy link
Member

mikebeaton commented Apr 22, 2020

UpdateUsing is what you should be using if you want to specify a where clause but the example you show shouldn't need a where clause: the object has a primary key and the instance of MightyOrm knows which the primary key field is.

The only thing I can think of is, are you sure you have the equivalent of , "PersonID"); in your own code? If not, Mighty won't know what the PK is and so it may be giving that (misleading) error message because of that.

Let me know about that, and I'll try to make some time to look into it some more ... if it is what I am suggesting, then I should probably figure out a way to specify that providing a primary key field would also have solved the problem, in those cases where it would (which IIRC unfortunately isn't all of the cases where that error message can show up!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants