Hi. I am almost a total novice to Linq2Sql notions except for few How Do I series videos :)
I have some classes in my DataContext.
GartPTSDataContext GetDataContext() {
SqlConnectionStringBuilder sb =
new SqlConnectionStringBuilder(Settings.Default.DBConnection);
sb.Password = "sql";
GartPTSDataContext dtx = new GartPTSDataContext(sb.ToString());
return dtx;
}
Then in one function I do
GartPTSDataContext dtx = GetDataContext();
var ptnList = from p in dtx.G12_PTSLists select p;
bsFullPTNList.DataSource = ptnList;
and in bindingsource_CurrentChanged
(for bsFullPTNList
) I do
if (CurrentPTS==null)
return; //bsFullPTNList.Current
GartPTSDataContext dtx = GetDataContext();
//Fill neighbour's grid
var neigbQry= from ptns in dtx.G12_PTSLists
join ng in dtx.G12_PTS_Neighbours
on ptns.UnitID equals ng.PTN_ID
where ptns.UnitID==CurrentPTS.UnitID
select ptns;
bsNeighbours.DataSource = neigbQry;
//fill full PTN list except for current PTN and existing neighbours
bsAllowedPTNList.DataSource = from p in dtx.G12_PTSLists
where !neigbQry.Contains(p)
select p;
As a result I get that DataGrids bound to bsFullPTNList
and bsAllowedPTNList
respectively become synchronized whereas I need them to be independent.
What am I missing here?