Veronique
Veronique

Reputation: 1

How to perform a simple update using Subsonic ,in Visual STudio(c#)

I have a very simple update.According to the ID of the table,I want to set a boolean column to true.The problem is that I my knowledge to subsonic is like 'pitch black'.

I have done the following but it does not work.

new SubSonic.Update(FundReturn.Schema).Set(FundReturn.Columns.IsDeleted).EqualTo(1)
          .Where(FundReturn.Columns.FundId).IsEqualTo(Convert.ToInt32(row.RecordID)).Execute();

The above line seems very logical,however it does not work.

I would appreciate any help given

Upvotes: 0

Views: 941

Answers (2)

Dave Neeley
Dave Neeley

Reputation: 3635

Guessing here, but instead of setting IsDeleted to '1' like it would appear in the database, set it to 'true' because the property you are working with is probably interpreted as a boolean in the generated code. SubSonic will automatically handle this and the RecordId conversion for you.

new SubSonic.Update(FundReturn.Schema).Set(FundReturn.Columns.IsDeleted).EqualTo(true)
     .Where(FundReturn.Columns.FundId).IsEqualTo(row.RecordID).Execute();

Upvotes: 2

JTtheGeek
JTtheGeek

Reputation: 1713

Woah there.... it's a lot simpler that you might be thinking....

var objActiveRecord = SomeActiveRecordType.SingleOrDefault(o => o.Id == iId);
objActiveRecord.SomeBoolProperty = true;
objActiveRecord.Update();

Upvotes: 0

Related Questions