I tried to write the DBFunctionCall expression using substring, however, I wasn't sure how to bring in the & operator and the > comparison.
long lRoleKey = Security.GetRoleKey(); //This line gets the role of the current user.
int iFoo1 = (lRoleKey/8)++;
byte byFoo2 = Math.Pow(2, (lRoleKey % 8 - 1));
DataAccessAdapter adapter = new DataAccessAdapter();
EntityCollection<CustomerEntity> ecCustomer = new EntityCollection<CustomerEntity>(new CustomerEntityFactory());
RelationPredicateBucket filter = new RelationPredicateBucket();
/*This is where I get stuck*/
filter.PredicateExpress.Add((DBFunctionCall("SUBSTRING", new object[]{CustomerFields.SecurityMask, iFoo1, 1}) & byFoo2) > 0);
/* I know the above code doesn't even compile*/
adapter.FetchEntityCollection(ecCustomer, filter);
The SQL code I am trying to end up with is:
SELECT * FROM Customer
WHERE SUBSTRING(Customer.SecurityMask, Foo1, 1) & Foo2 > 0
SecurityMask is a binary 10 field, I hope that makes more sense.