RE: Linq SubmitChanges and DataLoadOptions

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hello Chuck,
Thanks for your reply.

If you have set Auto-Sync on the columns, LINQ to SQL will fetch them back
after UpdateChanges() method. For Identity Columns or Calculated Columns,
those columns will be set as "Auto-Sync" in LINQ to SQL. Please check
"Auto-Sync" property on columns in .dbml file. You will found the reason
why LINQ to SQL retrieve Identity Columns in UpdateChanges() method. If you
have columns that are also generated at the database, set Auto-Sync on
those columns and LINQ to SQL will fetch them back. Moreover, when tracing
query on SQL server, you can found the generated select query only fetch
the related column from database, rather than fetch the whole row from
database. Thus, child rows aren't loaded from database.

In general, updating Master Table shouldn't clear the Detailed records. How
did you edit the master records? I tried the code which you pasted in
thread on my side. It seems fine. HasLoadedOrAssignedValues property
returns True after I Submitted Changes to database.

using (DataClasses1DataContext dc = new DataClasses1DataContext())
{
dc.Log = Console.Out;
DataLoadOptions lo = new DataLoadOptions();
lo.LoadWith<Table_1>(s => s.Table_11s);
dc.LoadOptions = lo;
var query = from obj in dc.Table_1s
where obj.c1 == 2
select obj;
Table_1 job = query.Single();
job.c2 = "10";
dc.SubmitChanges();

System.Console.WriteLine(job.Table_11s.HasLoadedOrAssignedValues);
}

Am I missing anything here? Please don't hesitate to correct me. I will try
again on my side. We are glad to assist you.

Have a great day,
Best regards,
Wen Yuan

Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

.



Relevant Pages

  • Re: How to benchmark LINQ query?
    ... should suffice with LINQ to SQL to fetch the data from the data base server to your client application. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Are Linq-SQL methods commutative
    ... No - in LINQ each step effectively works off the result of the ... linq query which has to meet a SQL query they have in mind. ... freedom a SQL statement gives them: the SQL statement is the one ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: LINQ Where 1=0
    ... The LinqDataSource control stores values for all primary keys ... Before LINQ to SQL updates or deletes data, it checks the values in view ... If the underlying data source contains a timestamp field that is ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Why cant recursive queries contain...?
    ... imagine that you have a gross amount of data spread ... SQL, and the optimizer will make sure that you get a new query plan as ... If you really think the limitation of 8000 chars gets in your way, ... The analogy was not meant to denigrate LINQ ...
    (microsoft.public.sqlserver.programming)
  • Re: MySQL VARCHAR missing value content
    ... All of the records that is supposed to FETCH is intact though... ... If the SQL is wrong, ... Procedure Division using lnk-DBI ... At the end of the game,, I do NOT need to return the info in lnk-DBI back to the DBI class - granted, using the Animator to take a look I will see different Hex value references to the Collection in the DBI Class and in this method; but they are both 'pointers' to the same object reference. ...
    (comp.lang.cobol)