The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Modify WHERE clause in base collection class

Last post 08-12-2008, 5:54 PM by Mike.Griffin. 1 replies.
Sort Posts: Previous Next
  •  08-12-2008, 11:51 AM 10697

    Modify WHERE clause in base collection class

    I am using a base class for my collections.  All of my tables have the column "UseId" which is an integer column.  I would like to override the "LoadAll()" method in my base class so that I can ensure the data I load for any given collection only returns the ID of the current user.

    Here is my base class:

     

    Code:
    1    using System;
    2    using System.Collections.Generic;
    3    using System.Text;
    4    using EntitySpaces.Core;
    5    using EntitySpaces.Interfaces;
    6    
    7    namespace DaymarkSoftware.iRaceMark.DAL {
    8      public class CollectionBase : esEntityCollection {
    9    
    10       public DotNetNuke.Entities.Users.UserInfo DNNUserInfo {
    11         get { return DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(); }
    12       }
    13   
    14       public override bool LoadAll() { 
    15         // TODO: Add logic to always filter on user id.
    16         return base.LoadAll();
    17       }
    18     }
    19   }
    20   
    

     I would like to do something like:

     

    Code:
    1    public override bool LoadAll() {
    2          es.Query.Where(es.Meta.Columns["UserID"].Equals(DNNUserInfo.UserID));
    3          return es.Query.Load();
    4        }
    
     
  •  08-12-2008, 5:54 PM 10702 in reply to 10697

    Re: Modify WHERE clause in base collection class

    You can generically add things to the where command via OP() like this, not sure if this is quite what you're after:

    CustomersQuery q = customer.Query;
    q.Where(q.ContactTitle.OP(esWhereOperand.Like,"%foo%"));

    The problem is where "ContactTitle" is above you want to determine dynamically, let me whip up a sample, I know it's here on the forums somewhere too, I'll find it.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
View as RSS news feed in XML