本文整理汇总了C#中PredicateExpression.AddWithAnd方法的典型用法代码示例。如果您正苦于以下问题:C# PredicateExpression.AddWithAnd方法的具体用法?C# PredicateExpression.AddWithAnd怎么用?C# PredicateExpression.AddWithAnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PredicateExpression
的用法示例。
在下文中一共展示了PredicateExpression.AddWithAnd方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMember
public MembershipEntity GetMember(string uName, string password)
{
MembershipCollection memberships = new MembershipCollection();
PredicateExpression filter = new PredicateExpression();
filter.AddWithAnd(MembershipFields.UserName == uName);
filter.AddWithAnd(MembershipFields.Password == Business.Encryption.SHA1Encryption.EncryptMessage(password));
filter.AddWithAnd(MembershipFields.Status == true);
memberships.GetMulti(filter);
if (memberships.Count > 0)
return memberships.FirstOrDefault();
else
return null;
}
示例2: FilterValidEntities
/// <summary>
/// Returns valid entities which are valid for given moment in time.
/// Valid entities have:
/// 1. Begining is not NULL AND is LESS than given moment in time.
/// 2. End is NULL OR is GREATER OR EQUAL than given moment in time.
/// </summary>
public static PredicateExpression FilterValidEntities(DateTime momentInTime,
EntityField2 validFromDateTimeField,
EntityField2 validToDateTimeField)
{
PredicateExpression predicateExpression = new PredicateExpression();
predicateExpression.Add(validFromDateTimeField != DBNull.Value & validFromDateTimeField <= momentInTime);
predicateExpression.AddWithAnd(validToDateTimeField == DBNull.Value | validToDateTimeField >= momentInTime);
return predicateExpression;
}
示例3: GetByNumberAndEvent
public Auction.Domain.Bidder GetByNumberAndEvent(int number, long eventId, ref IAuctionTransaction trans)
{
using(var records = new BidderCollection())
{
var filter = new PredicateExpression(BidderFields.EventId == eventId);
filter.AddWithAnd(BidderFields.Number == number);
if(trans != null)
{
trans.Add(records);
}
records.GetMulti(filter, 1);
var b = records.ToList().FirstOrDefault();
return new Bidder() { Id = b.Id, Number = number, Name = b.Name, EventId = eventId, Phone = b.Phone };
}
}
示例4: KreirajPredicate
/// <summary>
/// Za svaki član this.rules kolekcije kreira jedan Predicate.
/// Ako je rules.Count == 0 vraća NULL
/// </summary>
/// <returns>PredicateExpression</returns>
/// <param name="entityFieldsType">Ako se filtrira artikl onda typeof(ArtiklFields)</param>
/// <param name="getEntityFieldTypeFunction">Funkcija prima string (EntityFields type name) a vraća tip. Ako se desi da se filtrira po entitetu vezanom na glavni entitet (RacunGlava.Partner) tada se koristi ova funkcija za dohvat EntityFieldsType preko refleksije.</param>
public PredicateExpression KreirajPredicate(Type entityFieldsType,
Func<string, Type> getEntityFieldTypeFunction)
{
PredicateExpression toReturn = null;
if (rules.Count() > 0)
{
toReturn = new PredicateExpression();
foreach (JqGridFilterItem item in rules)
{
Predicate predicateToAdd = JqGridFilter.KreirajPredikatIzJqGridFilterItem(entityFieldsType, item, getEntityFieldTypeFunction);
if (predicateToAdd != null)
{
if (groupOp.ToUpper() == "AND")
{
toReturn.AddWithAnd(predicateToAdd);
}
else if (groupOp.ToUpper() == "OR")
{
toReturn.AddWithOr(predicateToAdd);
}
}
}
}
return toReturn;
}
示例5: BuildPredicateTree
private static IPredicate BuildPredicateTree(Func<string, IEntityField2> fieldGetter, Func<string, List<IEntityRelation>, IEntityField2> relatedFieldGetter, FilterNode filterNode, List<IEntityRelation> inferredRelationsList)
{
if (filterNode.NodeCount > 0)
{
if (filterNode.NodeType == FilterNodeType.Root && filterNode.Nodes.Count > 0)
{
if (filterNode.NodeCount == 1)
return BuildPredicateTree(fieldGetter, relatedFieldGetter, filterNode.Nodes[0], inferredRelationsList);
var predicate = new PredicateExpression();
foreach (var childNode in filterNode.Nodes)
{
var newPredicate = BuildPredicateTree(fieldGetter, relatedFieldGetter, childNode, inferredRelationsList);
if (newPredicate != null)
predicate.AddWithAnd(newPredicate);
}
return predicate;
}
else if (filterNode.NodeType == FilterNodeType.AndExpression ||
filterNode.NodeType == FilterNodeType.OrExpression)
{
var predicate = new PredicateExpression();
foreach (var childNode in filterNode.Nodes)
{
var newPredicate = BuildPredicateTree(fieldGetter, relatedFieldGetter, childNode, inferredRelationsList);
if (newPredicate != null)
{
if (filterNode.NodeType == FilterNodeType.OrExpression)
predicate.AddWithOr(newPredicate);
else
predicate.AddWithAnd(newPredicate);
}
}
return predicate;
}
}
else if (filterNode.ElementCount > 0)
{
// convert elements to IPredicate
var nodePredicate = BuildPredicateFromClauseNode(fieldGetter, relatedFieldGetter, filterNode, inferredRelationsList);
if (nodePredicate != null)
return nodePredicate;
}
return null;
}
示例6: RemoveFromEvent
public void RemoveFromEvent(long donorId,
long eventId,
ref IAuctionTransaction trans)
{
using (var records = new AuctionEventDonorCollection())
{
var filter = new PredicateExpression { AuctionEventDonorFields.DonorId == donorId };
filter.AddWithAnd(AuctionEventDonorFields.EventId == eventId);
records.DeleteMulti(filter);
}
}
示例7: CreateThreadFilter
/// <summary>
/// Creates the thread filter. Filters on the threads viewable by the passed in userid, which is the caller of the method.
/// If a forum isn't in the list of forumsWithThreadsFromOthers, only the sticky threads and the threads started by userid should
/// be counted / taken into account.
/// </summary>
/// <param name="forumsWithThreadsFromOthers">The forums with threads from others.</param>
/// <param name="userID">The user ID.</param>
/// <returns>ready to use thread filter.</returns>
internal static IPredicateExpression CreateThreadFilter(List<int> forumsWithThreadsFromOthers, int userID)
{
var threadFilter = new PredicateExpression();
if((forumsWithThreadsFromOthers != null) && (forumsWithThreadsFromOthers.Count > 0))
{
PredicateExpression onlyOwnThreadsFilter = new PredicateExpression();
// accept only those threads who aren't in the forumsWithThreadsFromOthers list and which are either started by userID or sticky.
// the filter on the threads not in the forums listed in the forumsWithThreadsFromOthers
if(forumsWithThreadsFromOthers.Count == 1)
{
// optimization, specify the only value instead of the range, so we won't get a WHERE Field IN (@param) query which is slow on some
// databases, but we'll get a WHERE Field == @param
// accept all threads which are in a forum located in the forumsWithThreadsFromOthers list
threadFilter.Add((ThreadFields.ForumID == forumsWithThreadsFromOthers[0]));
onlyOwnThreadsFilter.Add(ThreadFields.ForumID != forumsWithThreadsFromOthers[0]);
}
else
{
// accept all threads which are in a forum located in the forumsWithThreadsFromOthers list
threadFilter.Add((ThreadFields.ForumID == forumsWithThreadsFromOthers));
onlyOwnThreadsFilter.Add(ThreadFields.ForumID != forumsWithThreadsFromOthers);
}
// the filter on either sticky or threads started by the calling user
onlyOwnThreadsFilter.AddWithAnd((ThreadFields.IsSticky == true).Or(ThreadFields.StartedByUserID == userID));
threadFilter.AddWithOr(onlyOwnThreadsFilter);
}
else
{
// there are no forums enlisted in which the user has the right to view threads from others. So just filter on
// sticky threads or threads started by the calling user.
threadFilter.Add((ThreadFields.IsSticky == true).Or(ThreadFields.StartedByUserID == userID));
}
return threadFilter;
}
示例8: RemoveUsersFromRole
/// <summary>
/// Removes all users which ID's are stored in UsersToRemove, from the role with ID RoleID.
/// </summary>
/// <param name="userIDsToRemove">ArrayList with UserIDs of the users to Remove</param>
/// <param name="roleID">ID of role the users will be removed from</param>
/// <returns>true if succeeded, false otherwise</returns>
public static bool RemoveUsersFromRole(List<int> userIDsToRemove, int roleID)
{
if(userIDsToRemove.Count<=0)
{
return true;
}
// we'll delete all role-user combinations for the users in the given range plus for the given role.
// if there's just one user, we'll use an optimization, as the range query will result in an IN (param, param... ) query,
// and an field IN (param) query, is much slower compared to field = param, at least on Sqlserver.
// produce the filter which will be used to filter out the entities to delete.
PredicateExpression filter = new PredicateExpression();
if(userIDsToRemove.Count == 1)
{
// use compare value predicate instead
filter.Add((RoleUserFields.UserID == userIDsToRemove[0]));
}
else
{
// add a range filter
filter.Add((RoleUserFields.UserID == userIDsToRemove));
}
// add the filter for the role as with AND.
filter.AddWithAnd((RoleUserFields.RoleID == roleID));
// delete the entities directly from the database. As this gives a single DELETE statement, we don't have to start a transaction manually.
RoleUserCollection roleUsers = new RoleUserCollection();
return (roleUsers.DeleteMulti(filter) > 0);
}