This is a migrated thread and some comments may be shown as answers.

fetch plan does not work ....

5 Answers 80 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
amir sherafatian
Top achievements
Rank 1
amir sherafatian asked on 15 Sep 2009, 12:58 PM

i have 4 class that i shown their implementation in below , and i use fetch plan to give appropriate resault of this table but fetch plan does not work properly:
my classes and the implementation fech group for their :

----------------------------------------------------

[Telerik.OpenAccess.

Persistent()]

 

public abstract class ORGContact

{

[Telerik.OpenAccess.

 

FetchField("InternalPersonnel")]

 

private string FFamily;

[Telerik.OpenAccess.

 

FetchField("InternalPersonnel")]

 

private string FName;

[Telerik.OpenAccess.

 

FetchField("InternalPersonnel")]

 

private ContactType FType;
.
. //other field that are not define in fetch group
.
}
----------------------------------------------------

[Telerik.OpenAccess.

Persistent(IdentityField = "FId")]

 

public class ORGPersonJob {

 

 

private int FId;

[Telerik.OpenAccess.

 

FetchField("InternalPersonnel")]

 

private ORGPerson FORGPerson;

[Telerik.OpenAccess.

 

FetchField("InternalPersonnel", Next = "InternalPersonnel")]

 

private ORGJob FORGJob;

 

.
. //other field that are not define in fetch group
.
}
----------------------------------------------------
[Telerik.OpenAccess.

 

 

Persistent(IdentityField = "FId")]

 

public class ORGPerson : ORGContact {

 

[Telerik.OpenAccess.

 

FetchField("InternalPersonnel")]

 

private int FId;

[Telerik.OpenAccess.

 

FetchField("InternalPersonnel", Next = "InternalPersonnel")]

[Telerik.OpenAccess.

 

Depend()]

 

private IList<ORGPersonJob> FORGPersonJobs;
.
. //other field that are not define in fetch group
.
}
----------------------------------------------------

[Telerik.OpenAccess.

Persistent(IdentityField = "FId")]

 

public class ORGJob {

 

 

[Telerik.OpenAccess.

 

FetchField("InternalPersonnel")]

 

private int FId;

 

private bool FArchive;

[Telerik.OpenAccess.

 

FetchField("InternalPersonnel")]

 

private string FTitle;
.
. //other field that are not define in fetch group
.
}
----------------------------------------------------
and i use this code to retrieve oppropriate fields , but this query resault only all fields of ORGPerson table :

scope.Transaction.Begin();

 

scope.Transaction.Commit();

scope.FetchPlan.Clear();

scope.FetchPlan.Add(

"InternalPersonnel");

 

scope.FetchPlan.MaxDepth = 3;

 

 

var query = (from q in scope.Extent<ORGPerson>()

 

 

where q.Type == EandE.Framework.Managers.Utilities.ContactType.InternalPerson

 

select q).ToList();

 

return query;

 

----------
where is my problem ??
i want only three field ("Name","Family","Job")

 

 

 

 

 

 

5 Answers, 1 is accepted

Sort by
0
amir sherafatian
Top achievements
Rank 1
answered on 16 Sep 2009, 07:08 AM
i work more in fetch plan and now i think the fetch plan work but i want this special fields ("Name,Family,Job.Title") in one record toghether containing in my query resault set to show in radgrid.
and this is my code front of my aspx file of radgrid (shown bellow) but i have no good resault again,and only name,family is assigned

<

telerik:RadGrid ID="RadGrid1" runat="server"

 

 

onneeddatasource="RadGrid1_NeedDataSource" AutoGenerateColumns="False">

 

<

MasterTableView>

 

 

<Columns>

 

 

 

<telerik:GridBoundColumn HeaderText="NAME" DataField="Name" ></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="FAMILY" DataField="Family" ></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="JOB" DataField="ORGJob.FTitle" ></telerik:GridBoundColumn>

 

 

 

</Columns>

 

<

RowIndicatorColumn>

 

<

HeaderStyle Width="20px"></HeaderStyle>

 

</

RowIndicatorColumn>

 

<

ExpandCollapseColumn>

 

<

HeaderStyle Width="20px"></HeaderStyle>

 

</

ExpandCollapseColumn>

 

</

MasterTableView>

 

</

telerik:RadGrid>

 


0
Zoran
Telerik team
answered on 16 Sep 2009, 11:52 AM
Hello amir sherafatian,

There are several anomalies that we noticed in your code. You mentioned that you want only three fields fetched using your fetch plan: "Name","Family","Job". In your class definitions, you have added a lot more fields to the "InternalPersonnel" fetch group. The Next parameter is also used which loads not only the fields you have marked as fetch fields in your ORGPerson class, but also from the ORGPersonJob and ORGJob classes as well.

Regarding your second post, does your ORGPerson class have property called ORGJob? If you want to present the ORGJob.Title in your RadGrid, then this property should be there. The ORGJob class should have a Title property on its own. Does the RadGrid give you exceptions when you try to present these fields or the values are just not evaluated?

If it is the second, then the case might be that your properties do not have the appropriate FieldAlias attributes that point which persistent field they wrap.

Best wishes,
Zoran
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
amir sherafatian
Top achievements
Rank 1
answered on 16 Sep 2009, 12:35 PM
my rad grid don`t give an exception but fill blank the column of ORGJob.FTitle
and i added field alias to related property
i use that three field only in rad grid , and in other cases i need to that other field that i mentioned as fetched field
and in my ORGPerson i have a field of a many-to-many join table (private IList<ORGPersonJob> FORGPersonJobs;)
and i try to grasp ORGJob.FTitle by using this join table (ORGPersonJob)
i change definition for adding fields that i need to fetch group like below but i can`t grasp appropriate resault
what do you think about this ?::

[Telerik.OpenAccess.Persistent()] 

 

public abstract class ORGContact
{

[Telerik.OpenAccess.FetchField("InternalPersonnel")]

 

 

private string FFamily;

[Telerik.OpenAccess.FetchField("InternalPersonnel")]

 

 

private string FName;
.
. //other field that are not define in fetch group
.
}

----------------------------------------------------
[Telerik.OpenAccess.Persistent(IdentityField = "FId")]

public class ORGPerson : ORGContact {

[Telerik.OpenAccess.FetchField("InternalPersonnel")]

 

 

private int FId;

[Telerik.OpenAccess.FetchField("InternalPersonnel", Next = "InternalPersonnel")]

[Telerik.OpenAccess.Depend()]

 

 

 

 

private IList<ORGPersonJob> FORGPersonJobs;
.
. //other field that are not define in fetch group
.
}
----------------------------------------------------

[Telerik.OpenAccess.Persistent(IdentityField = "FId")]

 

 

public class ORGPersonJob {

private int FId;

 

 [Telerik.OpenAccess.FetchField("InternalPersonnel", Next = "InternalPersonnel")]

private ORGJob FORGJob;

.
. //other field that are not define in fetch group
.
}

 

----------------------------------------------------

[Telerik.OpenAccess.Persistent(IdentityField = "FId")]

 

public class ORGJob {

[Telerik.OpenAccess.FetchField("InternalPersonnel")]

 

 

private int FId;

[Telerik.OpenAccess.FetchField("InternalPersonnel")]

 

 

private string FTitle;
.
. //other field that are not define in fetch group
.
}
----------------------------------------------------

 

 

 and after the set field aliases for property that i need to retrieve ORGJob.Title i use those like marked line , is that right ?

 

( DataField="ORGPersonJobs.ORGJob.Title" ) (reference to market line)
ORGPersonJobs = ORGPerson.ORGPersonJobs
ORGJob = ORGPersonJobs.ORGJob
Title = ORGJob.Title


    <
telerik:RadGrid ID="RadGridInternalPersonnel" runat="server" AllowMultiRowSelection="true"

 

 

    onneeddatasource="RadGrid1_NeedDataSource" AllowSorting="True" AutoGenerateColumns="False">

 

    <

MasterTableView DataKeyNames="Id">

 

 

 

 

    <Columns>

 

 

 

 

    <telerik:GridBoundColumn HeaderText="NAME" DataField="Name" ></telerik:GridBoundColumn>

 

 

 

 

    <telerik:GridBoundColumn HeaderText="FAMILY" DataField="Family" ></telerik:GridBoundColumn>

 

 

 

 

**  <telerik:GridBoundColumn HeaderText="JOB"                            
            DataField
="ORGPersonJobs.ORGJob.Title"></telerik:GridBoundColumn
>

 

 

 

 

    <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn"></telerik:GridClientSelectColumn>

 

 

 

 

    </Columns>

 

    <

RowIndicatorColumn>

 

    <

HeaderStyle Width="20px"></HeaderStyle>

 

    </

RowIndicatorColumn>

 

    <

ExpandCollapseColumn>

 

    <

HeaderStyle Width="20px"></HeaderStyle>

 

    </

ExpandCollapseColumn>

 

    </

MasterTableView>

 

 

 

 

    <ClientSettings>

 

 

 

 

    <Selecting AllowRowSelect="True" />

 

 

 

 

    </ClientSettings>

 

    </

telerik:RadGrid> 

 

0
Accepted
Zoran
Telerik team
answered on 17 Sep 2009, 11:51 AM
Hi amir sherafatian,

The way you try to present the ORGJob is not logically correct as the ORGPersonJobs field is a collection field. It has no property of type ORGJob(e.g. you can not state: ORGPersonJobs.ORGJob.Title). The ORGPersonJobs field has properties and methods relevant for an ICollection (Count,First() etc..).

The elements it contains are of type ORGJob. Since there can be more than one ORGJob for one ORGPerson object you can not present a Person.ORGPersonJobs.ORGJob.Title.

Regards,
Zoran
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
amir sherafatian
Top achievements
Rank 1
answered on 19 Sep 2009, 06:53 AM
tanks zoran
Tags
Databases and Data Types
Asked by
amir sherafatian
Top achievements
Rank 1
Answers by
amir sherafatian
Top achievements
Rank 1
Zoran
Telerik team
Share this question
or