so far I've never dealed with serious DB programming in "native" languages (I'm using the "native" word here as opposition to web-based languages like PHP, thus I assume C# is one of those "native" languages. Probably I should use different word, but I don't know any).
Thus I'm looking for a good example of DB application in C#. This example should show how to:
- add, remove, edit records
- list records
- handle relations
most important for me is to learn the proper way of doing the abo开发者_如何学Pythonve things, in example - avoiding loading the whole table to memory (hey, it might have 500 000 records [or more ;) ])
A good example of what I'm looking for is P4A demo - products catalog. This however is written in PHP ;) http://p4a.crealabsfoundation.org/demo/
First, good question because I don't know of any really good DeskTop/Db sample applications.
You will have to pick a technology first, C# is just the language. You've only indicated Desktop, that leaves you with a lot of choices:
- WinForms + DataSets (classic 2003 vintage)
- WinForms + DataReaders (more lowlevel)
- WinForms + Entity Framework
- WPF + DataSets
- WPF + Entity Framework
- WPF + MVVM + Entity Framework
- SilverLight + Entity Framework
- SilverLight + Data Services
More combinations are possible, and there are other (3rd party) ORMs such as NHibernate.
The WinForms+Datasets/DataReaders is the oldest and simplest tech but not very OOP. You will find a lot of small samples and videos on WindowsClient.NET. Don't overlook the VisualBasic samples.
I will call it very good for small applications, less suitable for larger ones.
The Entity Framework (EF) is newer, lots of (recent) blogging about details. I found one small but rather complete sample on MSDN (but I couldn't find an accompanying article). Do take a look if you consider an ORM.
Very good for larger applications as it supports better layering and (unit-)testing.
There are various examples in C#/.Net on codeplex (take for example MVC Music Store if you want to go with MVC and EF) and many other websites.
The examples you're looking for depend on what application you're building. You can go for Linq2SQL or EntityFramework (Linq2Entities) when working with the databases, if you're not very familiar with SQL (though it helps - a lot), or the classes in System.Data.SqlClient for example.
Either option allows you to do the operations you mentioned above.
Regards...
精彩评论