Click here to Skip to main content
15,884,099 members
Articles / Desktop Programming / WPF

Tasks managing app using MVVM and NHibernate

Rate me:
Please Sign up or sign in to vote.
4.71/5 (5 votes)
19 Jul 2012CPOL4 min read 27.3K   879   10  
Full sample on how to develop a MVVM desktop app with NHibernate (SQLite) backend
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="vallTasksDataSet" targetNamespace="http://tempuri.org/vallTasksDataSet.xsd" xmlns:mstns="http://tempuri.org/vallTasksDataSet.xsd" xmlns="http://tempuri.org/vallTasksDataSet.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
  <xs:annotation>
    <xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
      <DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
        <Connections>
          <Connection ConnectionStringObject="data source=C:\Desarrollo\Tasks\WpfApp\bin\Debug\nhibernate.db" IsAppSettingsProperty="false" Modifier="Assembly" Name="SQLite [nhibernate]" ParameterPrefix="@" Provider="System.Data.SQLite" />
        </Connections>
        <Tables>
          <TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="vAllTasksTableAdapter" GeneratorDataComponentClassName="vAllTasksTableAdapter" Name="vAllTasks" UserDataComponentName="vAllTasksTableAdapter">
            <MainSource>
              <DbSource ConnectionRef="SQLite [nhibernate]" DbObjectName="main.vAllTasks" DbObjectType="View" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="false" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="false" UserGetMethodName="GetData" UserSourceName="Fill">
                <SelectCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="true">
                    <CommandText>SELECT [CreateDT], [TaskHours], [Name], [Code] FROM [vAllTasks]</CommandText>
                    <Parameters />
                  </DbCommand>
                </SelectCommand>
              </DbSource>
            </MainSource>
            <Mappings>
              <Mapping SourceColumn="[CreateDT]" DataSetColumn="[CreateDT]" />
              <Mapping SourceColumn="[TaskHours]" DataSetColumn="[TaskHours]" />
              <Mapping SourceColumn="[Name]" DataSetColumn="[Name]" />
              <Mapping SourceColumn="[Code]" DataSetColumn="[Code]" />
            </Mappings>
            <Sources>
              <DbSource ConnectionRef="SQLite [nhibernate]" DbObjectName="main.vAllTasks" DbObjectType="View" FillMethodModifier="Public" FillMethodName="FillByDateAndCode" GenerateMethods="Both" GenerateShortCommands="true" GeneratorGetMethodName="GetDataByDateAndCode" GeneratorSourceName="FillByDateAndCode" GetMethodModifier="Public" GetMethodName="GetDataByDateAndCode" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="true" UserGetMethodName="GetDataByDateAndCode" UserSourceName="FillByDateAndCode">
                <SelectCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="true">
                    <CommandText>SELECT Code, CreateDT, Name, TaskHours FROM vAllTasks WHERE (CreateDT &gt;= @FechaInicio) AND (CreateDT &lt;= @FechaFin) AND (Code = @PrjCode) ORDER BY CreateDT DESC</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="true" AutogeneratedName="FechaInicio" ColumnName="CreateDT" DataSourceName="main.vAllTasks" DataTypeServer="datetime(8)" DbType="DateTime" Direction="Input" ParameterName="@FechaInicio" Precision="0" ProviderType="DateTime" Scale="0" Size="8" SourceColumn="CreateDT" SourceColumnNullMapping="false" SourceVersion="Current" />
                      <Parameter AllowDbNull="true" AutogeneratedName="FechaFin" ColumnName="CreateDT" DataSourceName="main.vAllTasks" DataTypeServer="datetime(8)" DbType="DateTime" Direction="Input" ParameterName="@FechaFin" Precision="0" ProviderType="DateTime" Scale="0" Size="8" SourceColumn="CreateDT" SourceColumnNullMapping="false" SourceVersion="Current" />
                      <Parameter AllowDbNull="true" AutogeneratedName="PrjCode" ColumnName="Code" DataSourceName="main.vAllTasks" DataTypeServer="text" DbType="String" Direction="Input" ParameterName="@PrjCode" Precision="0" ProviderType="String" Scale="0" Size="2147483647" SourceColumn="Code" SourceColumnNullMapping="false" SourceVersion="Current" />
                    </Parameters>
                  </DbCommand>
                </SelectCommand>
              </DbSource>
              <DbSource ConnectionRef="SQLite [nhibernate]" DbObjectName="main.vAllTasks" DbObjectType="View" FillMethodModifier="Public" FillMethodName="FillByDateTime" GenerateMethods="Both" GenerateShortCommands="true" GeneratorGetMethodName="GetDataByDateTime" GeneratorSourceName="FillByDateTime" GetMethodModifier="Public" GetMethodName="GetDataByDateTime" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="true" UserGetMethodName="GetDataByDateTime" UserSourceName="FillByDateTime">
                <SelectCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="true">
                    <CommandText>SELECT [CreateDT], [TaskHours], [Name], [Code]
FROM [vAllTasks]
WHERE [CreateDT] &gt;= @FechaInicio AND [CreateDT] &lt;=@FechaFin
ORDER BY [CreateDT] DESC</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="true" AutogeneratedName="FechaInicio" ColumnName="CreateDT" DataSourceName="main.vAllTasks" DataTypeServer="datetime(8)" DbType="DateTime" Direction="Input" ParameterName="@FechaInicio" Precision="0" ProviderType="DateTime" Scale="0" Size="8" SourceColumn="CreateDT" SourceColumnNullMapping="false" SourceVersion="Current" />
                      <Parameter AllowDbNull="true" AutogeneratedName="FechaFin" ColumnName="CreateDT" DataSourceName="main.vAllTasks" DataTypeServer="datetime(8)" DbType="DateTime" Direction="Input" ParameterName="@FechaFin" Precision="0" ProviderType="DateTime" Scale="0" Size="8" SourceColumn="CreateDT" SourceColumnNullMapping="false" SourceVersion="Current" />
                    </Parameters>
                  </DbCommand>
                </SelectCommand>
              </DbSource>
            </Sources>
          </TableAdapter>
        </Tables>
        <Sources />
      </DataSource>
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="vallTasksDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:EnableTableAdapterManager="True" msprop:Generator_DataSetName="vallTasksDataSet" msprop:Generator_UserDSName="vallTasksDataSet">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="vAllTasks" msprop:Generator_TableClassName="vAllTasksDataTable" msprop:Generator_TableVarName="tablevAllTasks" msprop:Generator_TablePropName="vAllTasks" msprop:Generator_RowDeletingName="vAllTasksRowDeleting" msprop:Generator_UserTableName="vAllTasks" msprop:Generator_RowChangingName="vAllTasksRowChanging" msprop:Generator_RowEvHandlerName="vAllTasksRowChangeEventHandler" msprop:Generator_RowDeletedName="vAllTasksRowDeleted" msprop:Generator_RowEvArgName="vAllTasksRowChangeEvent" msprop:Generator_RowChangedName="vAllTasksRowChanged" msprop:Generator_RowClassName="vAllTasksRow">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="_x005B_CreateDT_x005D_" msprop:Generator_ColumnVarNameInTable="_column_CreateDT_" msprop:Generator_ColumnPropNameInRow="__CreateDT_" msprop:Generator_ColumnPropNameInTable="__CreateDT_Column" msprop:Generator_UserColumnName="[CreateDT]" type="xs:dateTime" minOccurs="0" />
              <xs:element name="_x005B_TaskHours_x005D_" msprop:Generator_ColumnVarNameInTable="_column_TaskHours_" msprop:Generator_ColumnPropNameInRow="__TaskHours_" msprop:Generator_ColumnPropNameInTable="__TaskHours_Column" msprop:Generator_UserColumnName="[TaskHours]" type="xs:double" minOccurs="0" />
              <xs:element name="_x005B_Name_x005D_" msprop:Generator_ColumnVarNameInTable="_column_Name_" msprop:Generator_ColumnPropNameInRow="__Name_" msprop:Generator_ColumnPropNameInTable="__Name_Column" msprop:Generator_UserColumnName="[Name]" minOccurs="0">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="2147483647" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element name="_x005B_Code_x005D_" msprop:Generator_ColumnVarNameInTable="_column_Code_" msprop:Generator_ColumnPropNameInRow="__Code_" msprop:Generator_ColumnPropNameInTable="__Code_Column" msprop:Generator_UserColumnName="[Code]" minOccurs="0">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="2147483647" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Spain Spain
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions