Saving only single table changes in DbLinq

  • Thread starter Thread starter Andrus
  • Start date Start date
A

Andrus

I retrieve rows and change one retrieved row like

var l = ((from b in Db.Klients
order by b.Kood
select b).Skip(10).Take(5)).ToList();

l[0].Nimi="xxx";

I need to save this table changes only (actually only single row is
changed). I
tried

MTable<Klient> tbl = Db.GetTable<Klient>();
tbl.SaveAll();

and found that it does not save change since Db.GetTable<Klient>() returns
new object and
tbl.SaveAll() saves only this object.

How to fix ?

Andrus.
 
Andrus said:
I retrieve rows and change one retrieved row like

var l = ((from b in Db.Klients
order by b.Kood
select b).Skip(10).Take(5)).ToList();

l[0].Nimi="xxx";

I need to save this table changes only (actually only single row is
changed). I
tried

MTable<Klient> tbl = Db.GetTable<Klient>();
tbl.SaveAll();

and found that it does not save change since Db.GetTable<Klient>() returns
new object and
tbl.SaveAll() saves only this object.

How to fix ?

That sounds like a very DbLinq-specific question, and I suspect you
have more DbLinq experience than anyone else in the group. Could I
suggest you ask on the DbLinq mailing list?
 
That sounds like a very DbLinq-specific question, and I suspect you
have more DbLinq experience than anyone else in the group. Could I
suggest you ask on the DbLinq mailing list?

Jon, there is no such list.

I can formulate my guestion in more general way:

How to save single table in Linq-SQL ?

How to issue commands:

1. Submit all inserts, updates and deletes made only for all rows Customer
entity, do not touch other tables.

2. Submit all updates made for single Customer object ?

I read VCSE 2008 MSDN help and havent noticed this possibility.

Andrus.
 
1. Submit all inserts, updates and deletes made only for all rows Customer
entity, do not touch other tables.

2. Submit all updates made for single Customer object ?

Simplest way is to only edit the entities you want to update! To me it
makes sense to save the context in a single atomic operation,
otherwise how can you possibly enforce integrity?

However - specific to your question, you could probably use the
Table<T>.Attach() / AttachAll() methods to throw the object(s) onto a
new data-context (as modified) - similar to the approach for working
with disconnected data (i.e. long-lived [or serialized] objects and a
short-lived context)

Marc
 
Andrus said:
Jon, there is no such list.

That's quite scary. I would generally shy away from technology with no
appropriate community discussion.

If nothing else, you should mail the author of DbLinq.
I can formulate my guestion in more general way:

How to save single table in Linq-SQL ?

I don't know if it's even possible, but if it *is* possible, it's LINQ-
to-SQL specific. It's not something which comes under the umbrella of
LINQ itself.
 
Simplest way is to only edit the entities you want to update! To me it
makes sense to save the context in a single atomic operation,
otherwise how can you possibly enforce integrity?

I'm creating winforms MDI application.
To allow other form see some other form changes, single global database
context is required.

User can change a lot of forms simultaneously but every forms can change
only single table different for any other form.
Calling SubmitChanges() in one form will save changes in all forms, so this
is not possible.
However - specific to your question, you could probably use the
Table<T>.Attach() / AttachAll() methods to throw the object(s) onto a
new data-context (as modified) - similar to the approach for working
with disconnected data (i.e. long-lived [or serialized] objects and a
short-lived context)

I'm looking for a best approach for winforms application. I know 3
possibilities:

1. Using approach above, every form save operation must find all open
tables, loop over tem, Detach them all, save and then attach them all. Do
you think that this is reasonable ?

2. Create separate context for every form. Disadventages:
A. every forms read data from database, no local caching is available.
B. changes in form are not seen in some other form.

3. Use global context to retrieve data. Detach retrieved data, edit it
offline. For save operation, create new context
and attach detached data to this context.
Disanvantages:

A. changes in form are not seen in some other form.

What approach to use for winforms application, havent seen any information
about this ?

Andrus.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top