views:

429

answers:

8

I am using Subsonic v3.0.0.3 with the Linq templates. I am attempting to update a record in a SQL Server Express database with the following:

var db = new MyDB(Constants.Database);
db.Update<Contact>()
  .Set(d => d.FirstName == contact.FirstName)
  .Where(d => d.Id == contact.Id)
  .Execute();

I am receiving a NullReferenceException when this line is executed. The stack trace is as follows:

   at SubSonic.Query.Update.GetCommand()
   at SubSonic.Query.Update.Execute()

Any chance that someone may be able to suggest what the problem is?

+1  A: 

Hmm - I would say to make sure the connection string is present (I'll be fixing the error message for missing connection strings in the coming weeks) other than that - this looks like an issue - would you mind posting at Github?

Rob Conery
It should be throwing a meaningful error if the connection string is null: http://github.com/subsonic/SubSonic-3.0/blob/d258f4793f0fffae3cf0fa707fddbeb7f56b277c/SubSonic.Core/DataProviders/ProviderFactory.cs#L31
John Sheehan
It seems not to be a connection string issue - as I'm getting data from the database using similar conventions. I will certainly lodge it over at github.
Brad Leach
Thanks - I'm getting some buggy code contributions that I need to watch more closely - also I need some more tests :)
Rob Conery
A: 

I get the same issue. It it fixed?

BTW:I use SimpleRepository pattern.

Order order = repo.Single(c=>c.OrderID=orderid); order.ModifiedDate = DateTime.Now; repo.Update(order);

The exception is thrown when excute the update.

It is fixed in the github repository. You will need to grab it from there until Rob makes another build public.
Brad Leach
Yikes...took me like 2 hours tonight fighting with this issue. Rob, is there any way we (the community) can help speed up the releases? I love SubSonic, but I'm having trouble recommending the 3.0 release with all the bugs I've been experiencing. If there's anything I/we can do beyond filing reports I'd be happy to do it.
JC Grubbs
A: 

Same issue, only with update. All querying, deleting and adding works.

[NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet.] SubSonic.Query.Update.GetCommand() +352 SubSonic.Query.Update.Execute() +13 SubSonic.Repository.SimpleRepository.Update(T item) +162

A: 

Same issue here. Using ActiveRecord.

Can anybody tell us how to rectify this issue in the meanwhile?

Yogesh
Found a solution here until 3.0.0.4 comes out (I hope it fixes it):http://stackoverflow.com/questions/1178021/subsonic-3-0-0-3-update-exception
Yogesh
A: 

Same issue here. Using ActiveRecord. waite For 3.0.0.4 ! Thanks!

A: 

Same problem with repo.Update(o);

Surf-O-Matic
A: 

Same Issue with repo.Update()

Stacktrace:

 at SubSonic.Query.Update.GetCommand()
 at SubSonic.Query.Update.Execute()
 at SubSonic.Repository.SimpleRepository.Update[T](T item)
Gurdas Nijor
A: 

I did a simple update which give me an NullReferenceException FarmDB db = new FarmDB(); db.Update().Set(x => x.phone == "13679178184").Where(x => x.name == "marship").Execute();

After step into the code, I found the line in Query/update.cs L186 internal Setting CreateSetting(IColumn column, bool isExpression) { Setting s = new Setting { query = this, ColumnName = column.Name, ParameterName = (provider.ParameterPrefix + "up" + column.Name), IsExpression = isExpression, DataType = column.DataType };

The ColumnName = column.QualifiedName should be ColumnName = column.Name

After correct this, update runs well. Hope some one can check this.

Scott