c# - Proper way to use Linq with WPF -


I am looking for a good guide in the correct method of using Linq to Sql with WPF.

Most of the guides go barefoot only, such as how data is displayed from the database, but how can I save it back into the database? Can you answer this question or tell me Can you?

I have a separate data project because only one data will be used in the web page so that I have a repository method. This means that I have a different class that uses datacentext and has methods like GetAllCompanies () and GetCompanyById (int id).

1) Where is the collection is best to go back as IQueryable or should I

2) Why should I use the Observe Collection and also use it with Linux / Linux should do.

IQueryable

Some properties of linq units should be editable in the app so that I can set them in two-way mode. That could turn the object into an objective collection.

3) Whether the object in Observeable Collination is an example of the original linux unit and thus changes in the database (when called subchiangs) changes

Method in the repository There should be some chopped to save. But when should I call it? If a person edits a field but does not decide to save it, then he goes to another object and edits it and then press Save Press the original change not even saved? It does not remember the change in a linq unit object now.

4) When and how to call the changing changelog method

5) Should I have a datacontent as a member of the variable of the repository class or a method variable

To add a new row, I should create a new object in an event (push the "new" button) and then add it to the database using a repo method.

6) When I add the object to the database, there will be no new object in ObservableCollection. I refresh somehow.

7) I do not want to reuse the editing window when creating a new window, but it is not certain how to dynamically change from referencing the selected item from this new object with a list view. Any examples you can tell.

Many questions! I will answer some

1) Use the IQueryable instead of specifying a type that you want to query a LINQ on it instead of using the 'var' keyword.

2) Whenever there is a change in the number of objects in the collection, observation provides qualification information. In this way, a list control can refresh itself whenever a collection changes.

Note: You need to implement the INotifyPropertyChanged interface to notify property changes for different objects in the archive.

3) I recommend Linux institutions not storing storage directly in the archive. The reason for this is that if you want to return the changes to the database, you will need to open the datacontent that created the unit. This connection remains open and does not advise.

4) Whenever you want to make changes to the database, create a new data syntax, select the objects that you want to change, change their properties and call the SubmitChanges () method. Turn off DataContext later

5) As I said, whenever you want to select objects from a database or want to send changes to the database, create a new installation of the data contextecture .


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -