Refernce Entity is not auto fetching

Posts   
 
    
Posts: 24
Joined: 26-May-2011
# Posted on: 31-May-2011 09:28:12   

Hello to All Perivious I using Selfservise two class, and referance entity get itis value automitacly i.e. Employee gets EmployeeType automitacly. Now I am using Adopter module two class, in database FkValues stored but itis not dispaly corresponding field.(Both entity Releation maintain perfect)

please chcek the xaml: (It is working fine with self servise module)

<!-- Employee Contact Details Datagrid -->
        <DataGrid Grid.Row="2" Grid.Column=" 0" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True"
        ItemsSource="{Binding Employees}"
        SelectedItem="{Binding SelectedEmployee}"
        HorizontalScrollBarVisibility="Auto" >
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding PkEmployeeId}" Header="Employee ID" Width="100" />
                <DataGridTextColumn Binding="{Binding FirstName}" Header="First Name" Width="*" />
                <DataGridTextColumn Binding="{Binding LastName}" Header="Last Name" Width="*" />
                <DataGridTextColumn Binding="{Binding 
<!-- I try to display EmployeeTypeName, in Employee Table i stored FkEmplyeeTypeId-->

EmployeeType.EmployeeTypeName,UpdateSourceTrigger=PropertyChanged}" Header="Permissions" Width="120" /> <DataGridCheckBoxColumn Header="Active" Binding="{Binding IsActive}" Width="70"/> </DataGrid.Columns> </DataGrid>

<!-- second part of refence entity--> <!--Permissions-->
                    <StackPanel Orientation="Horizontal">
                        <TextBlock   Text ="Permissions"  Margin="5" Width="140" Style="{StaticResource FixedLabelStyle}"/>
                        <ComboBox Name="comboBox1" Width="150" TabIndex="3" 
                            ItemsSource ="{Binding EmploymentTypes}"
                            SelectedItem ="{Binding SelectedEmployee.EmployeeType,UpdateSourceTrigger=PropertyChanged}"
                            DisplayMemberPath="EmployeeTypeName"
                            IsSynchronizedWithCurrentItem="True"
                            Tag="Select Permissions"
                            IsEnabled="{Binding DisableControl,UpdateSourceTrigger=PropertyChanged}">
                        </ComboBox>
                    </StackPanel>

Thanks in advance.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 31-May-2011 11:45:20   

When you fetch Employees, do you also fetch EmployeeTypes with prefetchPaths?

Posts: 24
Joined: 26-May-2011
# Posted on: 31-May-2011 12:09:12   

I Fetch Employee Entity only. Which is Item source My Data grid. I requried to display EmployeeType of employee (<DataGridTextColumn Binding="{Binding EmployeeType.EmployeeTypeName}" Header="Permissions" Width="120" />). In my database Employee Table have FKEmployeeTypeId; hence I assumed EmployeeTypeName will be display auto.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 31-May-2011 12:57:23   

This is true n SelfServicing but not in adapter.

Selfservicing has LazyLoad, i.e. an entity can be fetched automatically at runtime when accessed. And that's why the EmployeeType wasfetched automatically for you.

In Adapter you have to fetch it manually (pre-fetch). And thus you should use a preftchPath to fetch the EmployeeType up-front.