本文整理汇总了C#中Criteria.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Criteria.Add方法的具体用法?C# Criteria.Add怎么用?C# Criteria.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Criteria
的用法示例。
在下文中一共展示了Criteria.Add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetChildren
private List<Channel> GetChildren(string ID)
{
Criteria c = new Criteria(CriteriaType.Equals, "ParentID", ID);
c.Add(CriteriaType.Equals, "State", 1);
//c.Add(CriteriaType.NotEquals, "ID", Channel.ID);
return Assistant.List<Channel>(c, new Order[] {new Order("index"), new Order("ID") });
}
示例2: InitCriteria
private void InitCriteria()
{
criteria = new Criteria(CriteriaType.None);
if (string.IsNullOrEmpty(KeyWord))
{
if (IncludeChildren && Channel != null)
{
criteria.Add(CriteriaType.Like, "ChannelFullUrl", Channel.FullUrl + "%");
}
else
{
criteria.Add(CriteriaType.Equals, "OwnerID", Channel.ID);
}
}
string tag = We7Helper.RemoveHtml(System.Web.HttpUtility.UrlDecode(Request["tag"]));
if (!String.IsNullOrEmpty(tag))
{
criteria.Add(CriteriaType.Like, "Tags", "%" + HttpUtility.UrlDecode(tag) + "%");
}
string title = We7Helper.RemoveHtml(System.Web.HttpUtility.UrlDecode(Request["title"]));
if (!String.IsNullOrEmpty(title))
{
criteria.Add(CriteriaType.Like, "Title", "%" + title + "%");
}
string channel = We7Helper.RemoveHtml(System.Web.HttpUtility.UrlDecode(Request["channel"]));
if (!String.IsNullOrEmpty(channel))
{
Channel ch = HelperFactory.Instance.GetHelper<ChannelHelper>().GetChannel(channel, null);
if (ch != null)
{
criteria.Add(CriteriaType.Like, "ChannelFullUrl", ch.FullUrl + "%");
}
}
string author = We7Helper.RemoveHtml(System.Web.HttpUtility.UrlDecode(Request["author"]));
if (!String.IsNullOrEmpty(author))
{
criteria.Add(CriteriaType.Equals, "Author", author);
}
if (!string.IsNullOrEmpty(KeyWord))
{
Criteria keyCriteria = new Criteria(CriteriaType.None);
keyCriteria.Mode = CriteriaMode.Or;
keyCriteria.AddOr(CriteriaType.Like, "Title", "%" + KeyWord + "%");
keyCriteria.AddOr(CriteriaType.Like, "Description", "%" + KeyWord + "%");
criteria.Criterias.Add(keyCriteria);
}
criteria.Add(CriteriaType.Equals, "State", 1);
}
示例3: GetThisArticle
/// <summary>
/// 获得当前栏目下的第一篇文章
/// </summary>
/// <returns></returns>
protected Article GetThisArticle()
{
string id = ChannelHelper.GetChannelIDFromURL();
Channel ch = ChannelHelper.GetChannel(id, null);
Criteria c = new Criteria(CriteriaType.Equals, "ChannelFullUrl", ch.FullUrl);
c.Add(CriteriaType.Equals, "State", 1);
Order[] os = new Order[] { new Order("Updated", OrderMode.Desc) };
List<Article> aList = Assistant.List<Article>(c, os, 0, 1, new string[]
{
"ID", "Title", "ChannelFullUrl",
"Created","Clicks",
"SN","Content","OwnerID","Updated","State"
});
if (aList != null && aList.Count > 0)
{
return aList[0];
}
else
{
return new Article();
}
}
示例4: GetRealData
/// <summary>
/// 获取真实数据
/// </summary>
private List<Article> GetRealData()
{
Criteria c = new Criteria(CriteriaType.None);
if (IncludeChildren)
{
c.Add(CriteriaType.Like, "ChannelFullUrl", Channel.FullUrl + "%");
}
else
{
c.Add(CriteriaType.Equals, "OwnerID", OwnerID);
}
c.Add(CriteriaType.Equals, "State", 1);
if (!String.IsNullOrEmpty(Tags))
{
c.Add(CriteriaType.Like, "Tags", "%'" + Tags + "'%");
}
Order[] os = new Order[] { new Order("IsShow", OrderMode.Desc), new Order("Updated", OrderMode.Desc) };
articles = Assistant.List<Article>(c, os, 0, PageSize, new string[]
{
"ID", "Title", "ChannelFullUrl",
"Created",
"SN"
});
return articles;
}
示例5: IsOnSchedule
protected bool IsOnSchedule ()
{
IEnumerable<ScheduledSessionEntity> sessions = null;
if (UnitOfWork.IsUnitOfWorkStarted ()) {
var repo = new LocalScheduledSessionsRepository ();
var criteria = new Criteria ();
criteria.Add (Condition.Equal<ScheduledSessionEntity> (x => x.Title, _session.Title));
sessions = repo.Find (criteria);
} else {
using (UnitOfWork.Start()) {
var repo = new LocalScheduledSessionsRepository ();
var criteria = new Criteria ();
criteria.Add (Condition.Equal<ScheduledSessionEntity> (x => x.Title, _session.Title));
sessions = repo.Find (criteria);
}
}
if (sessions != null && sessions.Count () > 0) {
return true;
} else {
return false;
}
}
示例6: QueryArticlesByChannel
/// <summary>
/// 根据栏目获取文章
/// </summary>
/// <param name="ch">栏目</param>
/// <param name="includechildren">包含子栏目</param>
/// <param name="from"></param>
/// <param name="PageSize">页大小</param>
List<Article> QueryArticlesByChannel(Channel ch, int from, int PageSize)
{
Criteria c = new Criteria(CriteriaType.None);
if (HasChildrenChannel)
{
c.Add(CriteriaType.Like, "ChannelFullUrl", ch.FullUrl + "%");
c.Add(CriteriaType.Equals, "State", 1);
}
else
{
c.Add(CriteriaType.Equals, "OwnerID", ch.ID);
c.Add(CriteriaType.Equals, "State", 1);
}
if (!String.IsNullOrEmpty(Tags))
{
c.Add(CriteriaType.Like, "Tags", "%'" + Tags + "'%");
}
Order[] os = IsShow
? new Order[] { new Order("IsShow", OrderMode.Desc), new Order("Updated", OrderMode.Desc) }
: new Order[] { new Order("Updated", OrderMode.Desc) };
return Assistant.List<Article>(c, os, from, PageSize,
new string[] { "ID", "Title", "Updated", "ChannelFullUrl", "Created", "SN" });
}
示例7: GetChildren
private List<Channel> GetChildren()
{
Criteria c = new Criteria(CriteriaType.Like, "FullUrl", Channel.FullUrl + "%");
c.Add(CriteriaType.Equals, "State", 1);
c.Add(CriteriaType.NotEquals, "ID", Channel.ID);
return Assistant.List<Channel>(c, new Order[] { new Order("ID") });
}
示例8: QueryArticlesByChannels
/// <summary>
/// 根据栏目获取文章
/// </summary>
protected List<Article> QueryArticlesByChannels()
{
#region 将非空的栏目ID添加到 ListOwnerID
List<string> ListOwnerID = new List<string>(); ;
if (!string.IsNullOrEmpty(OwnerID1))
ListOwnerID.Add(OwnerID1);
if (!string.IsNullOrEmpty(OwnerID2))
ListOwnerID.Add(OwnerID2);
if (!string.IsNullOrEmpty(OwnerID3))
ListOwnerID.Add(OwnerID3);
if (!string.IsNullOrEmpty(OwnerID4))
ListOwnerID.Add(OwnerID4);
if (!string.IsNullOrEmpty(OwnerID5))
ListOwnerID.Add(OwnerID5);
if (!string.IsNullOrEmpty(OwnerID6))
ListOwnerID.Add(OwnerID6);
if (!string.IsNullOrEmpty(OwnerID7))
ListOwnerID.Add(OwnerID7);
if (!string.IsNullOrEmpty(OwnerID8))
ListOwnerID.Add(OwnerID8);
if (!string.IsNullOrEmpty(OwnerID9))
ListOwnerID.Add(OwnerID9);
if (!string.IsNullOrEmpty(OwnerID10))
ListOwnerID.Add(OwnerID10);
#endregion
Criteria c = new Criteria(CriteriaType.None);
//c.Add(CriteriaType.Like, "ChannelFullUrl", ch.FullUrl + "%");
c.Add(CriteriaType.Equals, "State", 1);
if (!String.IsNullOrEmpty(Tags))
{
c.Add(CriteriaType.Like, "Tags", "%'" + Tags + "'%");
}
if (ListOwnerID.Count > 0)
{
Criteria cOr = new Criteria(CriteriaType.None);
cOr.Mode = CriteriaMode.Or;
foreach (string chID in ListOwnerID)
{
cOr.AddOr(CriteriaType.Equals, "OwnerID", chID);
}
c.Criterias.Add(cOr);
}
Order[] os = IsShow ? new Order[] { new Order("IsShow", OrderMode.Desc), new Order("Updated", OrderMode.Desc), new Order("ID", OrderMode.Desc) } : new Order[] { new Order("Updated", OrderMode.Desc), new Order("ID", OrderMode.Desc) };
return Assistant.List<Article>(c, os, 0, PageSize,
new string[] {"ID", "Title", "ChannelFullUrl", "Created", "SN"});
}