New Posts New Posts RSS Feed: How business object list handles from presentation layer
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

How business object list handles from presentation layer

 Post Reply Post Reply
Author
Dinesh View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Apr-2008
Location: United States
Posts: 4
Post Options Post Options   Quote Dinesh Quote  Post ReplyReply Direct Link To This Post Topic: How business object list handles from presentation layer
    Posted: 26-May-2008 at 8:39am
hi

Consider the following relationship with business object.

Member.SubAccounts returns subaccounts for the particular member
aSubaccount.transferLines returns the transferlines with that particular subaccount


i want to write one query with below condition at presenatation layer

  1.     "member", "Member.@MemberId"
  2.     "sub", "member/Subaccounts[SubaccountType <> '_Data_' and Closed = 0]"
  3.      "tl", "sub[SubaccountType = _Data]/TransferLines[Category IN (_Data_)]"
[ represents where clause

in BusinessLayer's i have one Business Object file(SubAccount.cs) i have write one statement like

foreach(transferline tl in this.transferlines)
  as current scenario ideablade returns all transferlines(lets say 500) records



i want transferlines to return records based on the condition 3(lets say it returns 30 records) which needs to be control from presentation layer.

When i am not specifying any query at presentation layer then it should consider all records at business layers

InShort, i want to write one query with the above various conditions in presentation so whenever particular business object referenced in business layer  then those business objects should satisfy the above condition.


pl. help me in this regards...

Regards.


Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 27-May-2008 at 3:04pm
Use a couple of SubQueries.
 
Here is an example where I used Employee instead of "member", Order instead "sub", and OrderDetail instead of "tl".  I want to get all of the OrderDetails from an Order that was sold by an Employee whose last name began with 'D'.
 

namespace ConsoleApplication2 {

 

  class Program {

    static void Main(string[] args) {

      PersistenceManager mPM = PersistenceManager.DefaultManager;

      EntityQuery query = new EntityQuery(typeof(OrderDetail));

      EntitySubquery subQuery =

        query.AddSubquery(EntityRelations.Order_OrderDetail,QueryDirection.ParentQuery);

      EntitySubquery subQuery2 =

        subQuery.AddSubquery(EntityRelations.Employee_Order, QueryDirection.ParentQuery);

      subQuery2.AddClause(Employee.LastNameEntityColumn, EntityQueryOp.StartsWith , "D");

      EntityList<OrderDetail > mOrderDetails = mPM.GetEntities<OrderDetail>(query);

      foreach (OrderDetail od in mOrderDetails) {

        Console.WriteLine(od.Order.Employee.LastName);

      }

      Console.ReadLine();

    }

  }

Back to Top
Dinesh View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Apr-2008
Location: United States
Posts: 4
Post Options Post Options   Quote Dinesh Quote  Post ReplyReply Direct Link To This Post Posted: 27-May-2008 at 10:31pm
Thanks for your reply..

consider below is my requirement

i want one query which executes from the presentation whatever condition specified in that query it needs to apply that condition whenever i reference navigation property.

so when i write this query at presentation with following condition.
  1.     "member", "Member.@MemberId"
  2.     "sub", "member/Subaccounts[SubaccountType <> '_Data_' and Closed = 0]"
  3.      "tl", "sub[SubaccountType = _Data]/TransferLines[Category IN (_Data_)]"

when i reference this.transferline in subaccount.cs(BL) file  then it should meet the condition 3.

i have written this conditions in presentation so whenever i reference subaccounts in layer (bL) other than the presentation it should remember that condition and returns those records which meet that criteria.

so is your query solution fufills this needs.

pl. help me in this regards.

Note :  In Current version of ideablade(DevForce EF V4) , we are not able to find EntitySubQuery Class.

 

Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 28-May-2008 at 8:44pm
Dinesh,
 
Taking a step back for a second on your initial post, the easiest implementation might just be a custom property or two.  For example, Member.OpenAccounts might return an EntityQuery with the appropriate clauses applied, and similarly something like SubAccount.FilteredTransferLines would do the same to filter transfer lines.  You could instead try to implement an AfterGetXX for these properties, but since it sounds like you want the filters applied for the UI but not for other uses, you'd need to have a switch of some sort to tell you when to apply the filter.
 
Another option would be to set up a handler for the EnittyManager.Fetching event, and then apply the filter within the handler as wanted.
 
David
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down