views:

1791

answers:

2

I have this working and getting data. However, everytime I page it calls the GetAllWebExceptions, which gets all of the web exceptions records from the database. How should paging be implemented? I've only seen examples with EntityFrameworks. Does anyone have a good example using the data source with POCO or is that still to come?

 <Grid x:Name="LayoutRoot" Background="White">
        <ria:DomainDataSource x:Name="ErrorLogDataSource" 
                              LoadMethodName="GetAllWebExceptions">
            <ria:DomainDataSource.DomainContext>
                <services:CMSContext />
            </ria:DomainDataSource.DomainContext>
        </ria:DomainDataSource>
        <data:DataGrid x:Name="DataGridExceptions" ItemsSource="{Binding ElementName=ErrorLogDataSource, Path=Data}" 
                       AutoGenerateColumns="True">
        </data:DataGrid>
        <dataControls:DataPager Source="{Binding Data, ElementName=ErrorLogDataSource}" 
                                PageSize="20" />

in the service:

[Query(PreserveName = true)]
public IEnumerable GetAllWebExceptions()
{
   return WebException.SelectAll("DATECREATED DESC");
}
A: 

Hey,

You should certainly be able to use a POCO class. However your query method needs to reference it by returning a generic IEnumerable, so the rest of the system knows at compile time of your type.

The requirement is your POCO class must have some notion of identity, made up of one or more members that are marked with the [Key] metadata attribute.

For example:

public class WebException {

    [Key]
    string id;
    // Or it could be a DateTime if you use time of occurrence as the key,
    // or anything else that is unique.

    // ...
    // Other members
}

public class ErrorManager : DomainService {

    public IEnumerable<WebException> GetAllWebExceptions() {
        return WebException.SelectAll("DATECREATED DESC");
    }
}

Hope that helps...

NikhilK
A: 

Take a look at Brad Abrams excellent walk-through on using POCO with RIA Services

jdiaz

related questions