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

fetch plan does not work ....

2 Answers 76 Views
Design Time (Visual Designer & Tools)
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 16 Sep 2009, 05:11 AM

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")

2 Answers, 1 is accepted

Sort by
0
amir sherafatian
Top achievements
Rank 1
answered on 16 Sep 2009, 07:10 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
IT-Als
Top achievements
Rank 1
answered on 16 Sep 2009, 07:16 AM
Hi amir,

Maybe I am misunderstanding your problem... sorry if it is the case.

Fetchplans in OA is used to instruct the OA runtime on what nodes in the object graph to fetch at once when querying a class extent.

Example:
You have a class Order and a class OrderDetail, An Order instance has a list of OrderDetail instances.

In some cases you need the Order instance alone and in other cases you need both the Order and the OrderDetail instance.
You do not define the OrderDetail list as part of the default fetch group, since this fetches the details in every case.
But, what you can do is to define a FetchPlan named say "FullOrder", which retrieves the Order instance and all OrderDetail instances for that order.
Then you have support for both cases. In case you just need the plain Order instance, you don't use a fetch plan, thus the fields in the default fetch group are fecthed. In case you need the full Order instance (including details), you use the fetch plan.

Think of fetchgroups and fetchplans like a way of finetuning your queries in specific use cases, where the lazy loading mechanism would take too long to execute (like you want the full Order, but need something on the OrderDetails too... a query will be issued for each of the details)

Hope this helps..

Regards

Henrik

Tags
Design Time (Visual Designer & Tools)
Asked by
amir sherafatian
Top achievements
Rank 1
Answers by
amir sherafatian
Top achievements
Rank 1
IT-Als
Top achievements
Rank 1
Share this question
or