fetch plan does not work ....

3 posts, 0 answers
  1. amir sherafatian
    amir sherafatian avatar
    42 posts
    Member since:
    Aug 2009

    Posted 16 Sep 2009 Link to this post

    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. amir sherafatian
    amir sherafatian avatar
    42 posts
    Member since:
    Aug 2009

    Posted 16 Sep 2009 Link to this post

    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>

     


  3. DevCraft banner
  4. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 16 Sep 2009 Link to this post

    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

Back to Top