Databinding via webservice

Posts   
 
    
zz9pa
User
Posts: 7
Joined: 13-Sep-2012
# Posted on: 14-Sep-2012 18:32:23   

Newbie alert...

Ok - so I've generated an OData webservice using LLBLGen - and I've added a service reference to my .net winforms project.. So - I'm not linking to the data directly - but via a webservice

In my form I've added a datagridview, and a BindingSource

Set the Bindingsource.datasource =webservice.OneOfMyEntities Set the Datagridview datasource to the binding source - and my rows magically appear simple_smile

Now - the question! smile

I can edit the cells in the grid but it doesnt seem to keep save to the data when I call the webservice.SaveChanges() Am I doing something stupid ? Can anyone point me in the right direction...

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-Sep-2012 07:43:03   

When you call SaveChanges, Are the entities actually changed?

David Elizondo | LLBLGen Support Team
zz9pa
User
Posts: 7
Joined: 13-Sep-2012
# Posted on: 16-Sep-2012 12:01:39   

If I debug.writeline the changed row in the bindingsource - it looks to have the new value in there. But - nothing seems to get called on the webservice when I call w.SaveChanges() (Even though I edited the row on the grid)

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 16-Sep-2012 21:39:50   

If you modify the entities directly and then call w.SaveChanges(), does that work? What runtime library version are you using? (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7720)

David Elizondo | LLBLGen Support Team
zz9pa
User
Posts: 7
Joined: 13-Sep-2012
# Posted on: 17-Sep-2012 11:25:51   

Yes - that works :

        user.Name = "Bob_"+newId;
        w.AddToUser(user);
        w.SaveChanges();

saves 'Bob_...' to my table..

But - doing it to the binding source doesnt.. ie. userBindingSource.Add(user);

adds it to my displayed grid - but w.SaveChanges doesnt save the new data to the database..

Like I said - I'm a newbie - so could be doing something really stupid!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 17-Sep-2012 17:15:11   

Which runtime library version (build no.) are you using?

zz9pa
User
Posts: 7
Joined: 13-Sep-2012
# Posted on: 18-Sep-2012 14:08:19   

In the designer - "About" shows "3.5 Final - TRIAL"

But - I'm fairly sure its a "frontend" thing - which is only using code generating by Visual Studion when importing the service..

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 18-Sep-2012 20:41:29   

Please check the following link to know how to get the runtime library version http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7720

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 19-Sep-2012 11:41:38   

The classes used on the client are the ones generated by VS.NET based on the OData service. The change tracking issue related to the grid binding is therefore out of our scope.

The context itself (the service) by default doesn't do any change tracking by itself. (Microsoft's design, not ours, this is completely MS code) You have to call UpdateObject() to mark it for update if you don't add custom code.

You can work around this by using this: http://msdn.microsoft.com/en-us/library/ee373844.aspx

Frans Bouma | Lead developer LLBLGen Pro
zz9pa
User
Posts: 7
Joined: 13-Sep-2012
# Posted on: 20-Sep-2012 11:27:01   

Thanks - that was just what it needed..

I was aware this wasnt a LLBLGen problem - just didnt know where else to ask simple_smile

For my future reference using :

        userBindingSource.DataSource =  new DataServiceCollection<UserEntity>(w.User);

instead of userBindingSource.DataSource = w.User;

seems to do the job..