Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

How to generate CRUD operations for an object
xomega
#1 Posted : Wednesday, August 8, 2012 5:03:06 PM(UTC)
xomega



If you have an object definition in your model that does not have any operations defined yet, then you can quickly add operations to Create, Read, Update, Delete and Read List for that object using the Model CRUD Operations generator. It will use the object's structure to create such operations according to the best Xomega design practices. Even if the generated operations and model enhancements have extra operations or configurations, they can be easily deleted from the model, as deleting existing things is much easier than adding new things.

As part of creating the operations the generator also defines a structure for the object's key to be used in the CRUD operations. It also defines the following three Xomega Framework data objects that can be generated for the UI view models: a criteria object based on the Read List input structure, a row object for each a row returned by the Read List and a data object for the details form based on the key structure and the read and update operations.

Here are the steps that need to be performed to add model CRUD operations.
  1. Open the properties of the Model CRUD Operations generator in the Model Enhancements generator folder.
  2. If you want the criteria input parameters of the generated Read List operation to also include comparison operators for advanced searching capabilities, then set the Generate Operators parameter to true. Otherwise set it to false.
  3. Select the file that contains your object that you need to add operations to.
  4. Make sure your objects in that file don't have any operations defined.
  5. Right-click on the file and select Generate > Model CRUD Operations to run the generator.
  6. Review the generated operations. Delete operations, structures and parameters that are not needed and add other structures or parameters as needed following the instructions on how to define a new operation.

Below is an example of the output from running the generator a on a simple invoice object.
Code:
<module xmlns="http://www.xomega.net/omodel"
        xmlns:xfk="http://www.xomega.net/framework"
        xmlns:wpf="http://www.xomega.net/wpf">
  <types>
    <type name="invoice number" base="integer">
      <config>
        <wpf:web-control use-in-grid="true">
          <asp:HyperLink xmlns:asp="clr-namespace:System.Web.UI.WebControls" runat="server"
                         NavigateUrl="~/Gen/_InvoiceObjectPage.aspx?Number={value}"/>
        </wpf:web-control>
      </config>
    </type>
  </types>
  <structs>
    <struct name="invoice key" object="invoice">
      <param name="temporary key" type="temporary key"/>
      <param name="number" required="false"/>
      <config>
        <xfk:data-object class="InvoiceObject"/>
      </config>
      <doc>
        <summary>Invoice key structure.</summary>
      </doc>
    </struct>
  </structs>
  <objects>
    <object name="invoice">
      <fields>
        <field name="number" type="invoice number" key="serial" required="true"/>
        <field name="customer" type="customer"/>
        <field name="total" type="money"/>
      </fields>
      <operations>
        <operation name="create">
          <output struct="invoice key"/>
        </operation>
        <operation name="read">
          <input struct="invoice key"/>
          <output>
            <param name="number"/>
            <param name="customer"/>
            <param name="total"/>
            <config>
              <xfk:add-to-object class="InvoiceObject"/>
            </config>
          </output>
        </operation>
        <operation name="update">
          <input>
            <param name="temporary key" type="temporary key"/>
            <param name="number"/>
            <param name="customer"/>
            <param name="total"/>
            <config>
              <xfk:add-to-object class="InvoiceObject"/>
            </config>
          </input>
        </operation>
        <operation name="delete">
          <input struct="invoice key"/>
        </operation>
        <operation name="read list">
          <input>
            <param name="customer operator" type="operator"/>
            <param name="customer" required="false"/>
            <param name="customer2" type="customer" required="false"/>
            <param name="total operator" type="operator"/>
            <param name="total" required="false"/>
            <param name="total2" type="money" required="false"/>
            <config>
              <xfk:data-object class="InvoiceCriteria"/>
            </config>
          </input>
          <output list="true">
            <param name="number"/>
            <param name="customer"/>
            <param name="total"/>
            <config>
              <xfk:data-object class="InvoiceRowObject"/>
            </config>
          </output>
        </operation>
      </operations>
    </object>
  </objects>
</module>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.