This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have several tables which are joined in the database. Table SecurityFunctions has a one to many relationship with Table OperatorPermissions which in turn has a one to many relationship with OperatorGroups. There are other tables joined, but these are where my problem exits. In my code I have obtained an IList for all the SecurityFunctions within a certain module. Using... var qry = new Query { QueryExpression = Entity.Attribute("Module") == _functionalArea }; var _secFuncs = uow.Find<SecurityFunction>(qry); This seems to work correctly. Next I need to iterate through all the _secFuncs, and using the relationship to OperatorPermissions, locate the securityLevel for a particular operatorGroup. I am trying to use... foreach(var func in _secFuncs) { var op = func.OperatorPermissions.Find(??????); // here we process the op.... } The problem is the ?????? I can't seem to find any information what goes here, I tried a query, but it says I need a predicate<T>. I have searched the LS documentation and website for a sample or explanation of this, but cannot find anything. Can anyone give me clue what goes there? I need to match a given value of _opGroup to equal a field in OperatorPermissions called OperatorGroupID. Any and all help will be greatly appreciated, as I have been trying to resolve this for a while. |
|
|
Hi Mark, The Find method is actually part of the base class for the EntityCollection which is a BindingList<T> or List<T> so thats why it isnt documentented specifically. You can find some documentation about this method on MSDN: http://msdn.microsoft.com/en-us/library/x0b5b5bc.aspx You would want to pass in a delegate to that method (or you can use a Lambda if you are using the 3.5 compiler) e.g. var op = func.OperatorPermissions.Find((OperatorPermission p) => { return p.OperatorGroupID == _opGroup; }); Bear in mind that if OperatorPermissions is being lazily loaded then this approach will cause the entire collection to be loaded so the Find() call can enumerate the collection.
Jeremy |
|
|
Hi Jeremy, Thanks for this rely. The information on using Lambda expressions was especially helpful, and worked a treat. Thanks Mark
|
|