hi
i am using LINQ to sql in my window application.
i have a grid that i display on it 2 tables from database that has a relation between them.
user can edit data on the grid and i update it on database.
today i dont bind the tables, i populate dataset with the 2 tables, define relation and set the dataset to be the datasource of the grid.
in addition, when user edit data i have a code that check what was updated and update it on database.
is there a simpler and more correct way to work?
how can i bind the 2 tables to the grid?
how can i update data automatically ?
(i am looking for somthing like dataset in ADO.net where these things are very simple. and somthing that will work with UltraWinGrid)
Thanks, Michal
Hi Michal,
I'm having a hard time understand what you are asking. Whether you use LINQ or a DataSet really makes no difference as far as the grid is concerned.
mrostoker said:is there a simpler and more correct way to work?
Simpler in what way? What's the problem with how it works now?
mrostoker said:how can i bind the 2 tables to the grid?
Since you say you are already doing this, I don't understand the question.
mrostoker said:how can i update data automatically ?
Changes you make in the grid are updated to the local data source. But the grid has no connection to your data base. That's nothing to do with the grid, it's simply how data binding works in DotNet.
that wasnt what i meant.
i was saying that using ADO.net you should only define insert update and delete statement (on the dataset) and every update in data is handled. i dont need to check every row and if the row was updated to run updating query to the database. once i defined on the dataset insert update and delete statement it is already being made.
what i was asking is about linq: is there a way to get with the data context 2 tables with relation from database, bind them to the grid and after user update data on the grid just run submit changes or somthing like that so that the updated values will be updated on database.
the thing i do right now is:
get 2 tables (with linq)
populate each one of them on datatable
add them to data set and define relation between them so that they will be displayed on 2 bands
adding column of state and when user update somthing on the grid i change state of the updated row
once user finish updating i get all updated records (according to the value on state column) and run with linq update query to data base
it is working but i dont think this is the correct way to do these things.
how should i do this?
mrostoker said:i was saying that using ADO.net you should only define insert update and delete statement (on the dataset) and every update in data is handled. i dont need to check every row and if the row was updated to run updating query to the database. once i defined on the dataset insert update and delete statement it is already being made.
It sounds to me like you are referring to the DataAdapter class. DataSets and DataTables in DotNet already track what data has changed and the DataAdapter class builds the SQL to update the back end for you. None of this has anything to do with the WinGrid, though.
I'm afraid I'm not really all that familiar with LINQ, so I don't know if there is any built-in capabilities for tracking changes and updating the back end. Again, that really has nothing to do with the WinGrid or any Infragistics control, it's really a general question about LINQ. You might want to try posting on a Microsoft or general DotNet programming forum.
The grid only deals with the local data source, it has no interaction with the back end.