views:

38

answers:

1

Hi

I am doing Silverlight 4

In my database, I have a store procedure(having two parameters) which returns rows (with extra fields). So i have to make a complex type for those rows on my Models. And Making a service to call that function import store procedure.

The RIA will automatically create a matching Entity(to the complex type) and an operation for me.

However, I don't know how to validation the parameters of the operation on both client and server side. For example, the parameter must be an integer only (and greater than 10) or datetime only.

below is my xaml code. I am using DomainDataSource control and don't know how to validate the two field parameter.It has two TextBox to let the user types in the value of parameters. Plz help me, thank you

 <riaControls:DomainDataSource AutoLoad="False" d:DesignData="{d:DesignInstance my1:USPFinancialAccountHistory, CreateList=true}" Height="0" LoadedData="uSPFinancialAccountHistoryDomainDataSource_LoadedData" Name="uSPFinancialAccountHistoryDomainDataSource" QueryName="GetFinancialAccountHistoryQuery" Width="0" Margin="0,0,705,32">
        <riaControls:DomainDataSource.DomainContext>
            <my:USPFinancialAccountHistoryContext />
        </riaControls:DomainDataSource.DomainContext>
        <riaControls:DomainDataSource.QueryParameters>
            <riaControls:Parameter ParameterName="fiscalYear" Value="{Binding ElementName=fiscalYearTextBox, Path=Text}" />
            <riaControls:Parameter ParameterName="fiscalPeriod" Value="{Binding ElementName=fiscalPeriodTextBox, Path=Text}" />
        </riaControls:DomainDataSource.QueryParameters>
    </riaControls:DomainDataSource>
    <StackPanel Height="30" HorizontalAlignment="Left" Orientation="Horizontal" VerticalAlignment="Top">
        <sdk:Label Content="Fiscal Year:" Margin="3" VerticalAlignment="Center" />
        <TextBox Name="fiscalYearTextBox" Width="60" />
        <sdk:Label Content="Fiscal Period:" Margin="3" VerticalAlignment="Center" />
        <TextBox Name="fiscalPeriodTextBox" Width="60" />
        <Button Command="{Binding Path=LoadCommand, ElementName=uSPFinancialAccountHistoryDomainDataSource}" Content="Load" Margin="3" Name="uSPFinancialAccountHistoryDomainDataSourceLoadButton" />
    </StackPanel>
    <telerik:RadGridView ItemsSource="{Binding ElementName=uSPFinancialAccountHistoryDomainDataSource, Path=Data}" Name="uSPFinancialAccountHistoryRadGridView" Grid.Row="1" 
                         IsReadOnly="True"
                         DataLoadMode="Asynchronous"
                         AutoGenerateColumns="False"
                         ShowGroupPanel="False">
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn Header="Account Number" DataMemberBinding="{Binding AccountNumber}"/>
            <telerik:GridViewDataColumn Header="Department Number" DataMemberBinding="{Binding DepartmentNumber}"/>
            <telerik:GridViewDataColumn Header="Period code" DataMemberBinding="{Binding PeriodCode}" />
            <telerik:GridViewDataColumn Header="Total Debit" DataMemberBinding="{Binding TotalDebit}" DataFormatString="{}{0:C2}"/>
            <telerik:GridViewDataColumn Header="Total Credit" DataMemberBinding="{Binding TotalCredit}" DataFormatString="{}{0:C2}"/>
            <telerik:GridViewDataColumn Header="Period Total" DataMemberBinding="{Binding PeriodTotal}" DataFormatString="{}{0:C2}"/>
            <telerik:GridViewDataColumn Header="Year To Date" DataMemberBinding="{Binding YearToDate}" DataFormatString="{}{0:C2}"/>
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>
A: 

If you follow the recommended practices, RIA Services will automatically take them into account both on the client and the server (i.e. code will be generated on the client with the same attributes and they will be respected). See this article by the man himself on how to handle validation.

Alex Paven
Hi Alex, I want to validate the typed parameters for the store procedure which are the text of fiscalYearTextBox and fiscalPeriodTextBox in my case. So i do need to put some attribute on the metaclass of my complex type?
Tai