This project is read-only.

Update with "Where" and "And"

Feb 8, 2010 at 10:25 AM

hi,

I want to update data with a where and And syntax if it is in SQL;

Heres the sql syntax

Update ProdImageGallery Set ProdImageGallery.sort= '1' Where ProdImageGallery.id = '1' And ProdImageGallery.sort = 2;

 

how will i code that in nHydrate?

Thanks

Feb 8, 2010 at 2:46 PM

You can update any single field on a collection by using the UpdateData static method.

ProdImageGalleryCollection.UpdateData(FIELD, WHERE, NEWVALUE);
ProdImageGalleryCollection.UpdateData(x => x.Sort, x => x.Id == 1 && x.Sort == 1, 1);

Mar 1, 2010 at 3:20 AM
Edited Mar 1, 2010 at 3:24 AM
codetools wrote:

You can update any single field on a collection by using the UpdateData static method.

ProdImageGalleryCollection.UpdateData(FIELD, WHERE, NEWVALUE);
ProdImageGalleryCollection.UpdateData(x => x.Sort, x => x.Id == 1 && x.Sort == 1, 1);

 Anyone here can translate to me the above two lines of code to VB.Net?

I use the appropriate object collection i have in my application but when i enter the FIELD, WHERE, NEWVALUE i get syntax error. plus the second line also generates syntax errors.

Thank you.

Apr 1, 2010 at 3:06 PM
Edited Apr 1, 2010 at 3:07 PM
codetools wrote:

You can update any single field on a collection by using the UpdateData static method.

ProdImageGalleryCollection.UpdateData(FIELD, WHERE, NEWVALUE);
ProdImageGalleryCollection.UpdateData(x => x.Sort, x => x.Id == 1 && x.Sort == 1, 1);

 Hi,

i want to update a collection of fields (e.g textBox1, textBox2, .... textBox10).
How can i do this in a simple way? Or is there no other possibility to update the data and i musst 10 times write the update command ( for every textBox)?

Thx

Apr 2, 2010 at 4:10 AM

Currently the bulk update functionality is for a single field so you cannot update multiple fields on multiple rows at one time. To update multiple fields on multiple rows in one transaction you will need to query the objects, which loads them in memory with the static method RunSelect and set the specific field of the loaded objects and call Persist. The bulk update is a convenience exposed for single fields only right now.