Data representation with C# and WPF

I’m developing an application handling DB parts. I retrieve the data from the DB with stored procedures and prepared statements. Now I want to display the data in the GUI.

What is the current technology used for that? Does one still use DataSet and DataTable for that?

3

There are different tools and different patterns.

Tools

ADO.NET

ADO.NET is much more than DataSet and DataTable. I would not use those classes in any project but instead use the IDataReader to populate pocos as I describe here: http://blog.gauffin.org/2013/01/ado-net-the-right-way/

Data mappers

The next step is to use a data mapper. What they do is to let you write SQL statements, but they will automatically return POCOs to you. Either as a dynamic representation or as T4 generated classes. (You can also map your own classes)

Some examples are Massive, PetaPoco and Simple.Data.

OR/Ms

Object/Relation mappers are the most complex approach (complex as in creating). They take care of everything for you. Most OR/Ms also has a LINQ to SQL provider. That is, you can write LINQ statements which then are converted to SQL.

Entity framework for instance has a visual designer in which you can point at the tables/columns that you want to get classes for. Hence it’s quite easy to get started.

Examples: Lightspeed, Entity Framework and nhibernate.

Patterns

Patterns help you structure the code in the data access layer.

Repository pattern

Repository pattern is quite old but still a relevant pattern. The idea is to abstract away the data access to reduce coupling and complexity.

Query object

The query object pattern is used to create a class per query. For instance, it makes it easier to see which parameters are required (constructor arguments) and which are optional.

CQS

Command/Query separation is a way to separate querying (fetching) and commands (storing) information. It’s not just a data access pattern but a way to structure your application.

CQRS

CQRS is similar to CQS but takes it a step further. It uses separate models (databases) for reads and writes. The read model is typically generated with the help of events from the writes.

WPF

In WPF you have view models which you use to map the GUI to your data access. You use ObservableCollection to get a GUI which responds to changes.

In the view model you’ll use any of the tools that I described above (directly or through one of the described patterns).

Additional info

I’ve written a blog post about the data layer here: http://blog.gauffin.org/2013/01/data-layer-the-right-way/ where I discuss the data access.

imho stored procedures are obsolete. Parameterized queries are in many databases as fast as stored procedures.

1

What is the current technology used for displaying Data? Does one still use DataSet and DataTable for that?

Well, taking into account your project needs it can really wary what to use, and what client design pattern to choose from.

However, the main point is not to over-complicate things (project design) that you are planning to achieve. Because, each design pattern has purpose to solve some common business problems, and implementing them for the sake of saying stating that project uses blah.. pattern has no value at all.

This is not to say that you should shun virtual functions, inheritance, or other features of modern programming languages. Far from it, often they not only add clarity and maintainability they also improve performance. But, as often, I find that people have written their code in some elaborate way when a much simpler model would have been equally servicable and more performant.

Thus, my advice would be to practice KISS and YAGNI principles.

Regarding MVVM pattern: It is a pattern designed to solve specific business problem which are combined under the term separation of concerns. Thus, you may consider it if it suits your project. For more readings on MVVM technical descriptions you may look here.

A good reading that may help you to clarify your decision regarding this pattern to look is – WPF Apps With The Model-View-ViewModel Design Pattern.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật