Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat are the best characteristics of a datalayer framework for WPF/MVVM applications?
    primarykey
    data
    text
    <p>I am creating a WPF/MVVM framework which generates the code for the model classes.</p> <p>I'm planning to have for each database-table/web-service (e.g. "Customers") <strong>two model classes</strong>:</p> <ul> <li>a singular model class (e.g. "Customer") </li> <li>and a plural model class (e.g. "Customers")</li> </ul> <p>The <strong>singular model class</strong> has all of its properties (FirstName, LastName, etc.) plus all of it methods which make sense for a singular instance, e.g. Save(), Delete(), CalculateSalary(), etc. </p> <p>The <strong>plural model class</strong> has a collection of singular model objects, plus the same methods since you would want to also perform on a group of singular objects, e.g. Save(), Delete(), CalculateSalary(), but also particular methods such as Sort(), and methods that made it very easy to certain groups, e.g. LoadAllGoldCustomers(), or even LoadWithSql(string sql), etc.</p> <p>I've done a framework like this before (PHP) and it made for very easy to write and understand code like this:</p> <pre><code>Customers customers = new Customers("all"); customers.CalculateSalary(); </code></pre> <p>A couple inherited classes (Item and Items) took most of the code out of the individual singular and plural classes for each database table, which made a very clean environment to program in.</p> <p>However, <strong>I have rarely seen other applications do this</strong> singular/plural model class split. Instead, there is almost always just one class for each database table, e.g. <code>Customer</code> and this class has any plural methods necessary, e.g. GetCustomers(string sql), etc.</p> <p>I just noticed in the <a href="http://www.codeplex.com/wpf/Release/ProjectReleases.aspx?ReleaseId=14962" rel="nofollow noreferrer">WPF Model-View-ViewModel Toolkit 0.1</a> walkthrough, they have you make two models their "Models" directory two classes:</p> <ul> <li>Customer.cs (fields only)</li> <li>CustomersDataSource.cs (one List Load() method)</li> </ul> <p>Which <strong>seems to be a similar concept</strong>, just that the "plural" class is called a DataSource. </p> <p>So now I am about to make another framework based in WPF/MVVM and can decide how I want to structure the model classes. I want the framework to be:</p> <ul> <li><strong>clear and easy to program against from the ViewModel</strong>, hence the clear separation of singular and plural model classes, you should just have to instantiate a singular or plural class and call a method on it and you have your data.</li> <li><strong>fit in well with the MVVM pattern</strong> (which I understand means to keep as simple as possible, just have properties and methods that the ViewModel can call, but implement no WPF-specific features such as INotifyProperityChanged)</li> <li>want my datalayer to <strong>sit above any datasource</strong>, so if I use LINQ-to-SQL, I still call my own model classes, and if I want to switch to saving in Oracle, I write a lower data adapter layer for my classes to interact with that.</li> <li><strong>take advantage of LINQ</strong> in the best way possible</li> </ul> <p>I would appreciate feedback from those who have developed datalayers for frameworks especially using WPF/MVVM/Composite Application Library and what characteristics you found worked best, or if you have worked with other frameworks such as CSLA, Subsonic, etc. Also, any experience or ideas on how LINQ changes/simplifies building a datalayer structure. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload