本文整理汇总了C#中IServiceProvider.MaxInClauseElements方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceProvider.MaxInClauseElements方法的具体用法?C# IServiceProvider.MaxInClauseElements怎么用?C# IServiceProvider.MaxInClauseElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceProvider
的用法示例。
在下文中一共展示了IServiceProvider.MaxInClauseElements方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetMsgGroupReadReplies
private static void SetMsgGroupReadReplies(
IServiceProvider provider,
IEnumerable<int> mids,
bool readReplies)
{
if (mids == null)
throw new ArgumentNullException(nameof(mids));
using (var db = provider.CreateDBContext())
using (var tx = db.BeginTransaction())
{
foreach (var ids in mids.SplitToSeries(provider.MaxInClauseElements()))
{
var localIds = ids;
db
.Messages(m => localIds.Contains(m.ID))
.Set(_ => _.ReadReplies, readReplies)
.Update();
}
tx.Commit();
}
}
示例2: UpdateTopicInfoRange
public static void UpdateTopicInfoRange(
IServiceProvider provider,
IDataContext db,
IEnumerable<int> tids)
{
if (db == null)
throw new ArgumentNullException("db");
if (tids == null)
return;
foreach (var series in
tids
.SplitToSeries(provider.MaxInClauseElements()))
{
var locSeries = series;
UpdateTopicInfoByFilter(
db,
ti => locSeries.Contains(ti.MessageID),
m => locSeries.Contains(m.ID));
}
}
示例3: SearchMessagesByLucene
/// <summary>
/// Поиск и выборка данных с использованием Lucene
/// </summary>
public static List<MsgBase> SearchMessagesByLucene(
IServiceProvider provider,
int forumId,
string searchText,
bool searchInText,
bool searchInSubject,
bool searchAuthor,
bool searchInMarked,
bool searchInMyMessages,
bool searchAnyWords,
bool searchInQuestions,
DateTime from,
DateTime to)
{
provider.LogInfo("Начат поиск...");
var maxInClause = provider.MaxInClauseElements();
provider.LogInfo("Используется lucene...");
var mids =
Search(
forumId,
searchText,
searchInText,
searchInSubject,
searchAuthor,
//searchInMarked,
searchInMyMessages,
searchAnyWords,
//searchInQuestions,
from,
to);
if (mids.Count == 0)
return new List<MsgBase>(); // Ничего не нашли, вернём пустой список
if (mids.Count > maxInClause)
mids = Algorithms.GetFirstElements(mids, maxInClause);
var intMids = mids.Select(int.Parse);
using (var db = provider.CreateDBContext())
{
var q = db.Messages(m => intMids.Contains(m.ID));
q = q.OrderByDescending(m => m.ID);
// Обработка вопросов
if (searchInQuestions)
q = q.Where(m => m.TopicID == 0);
// Обработка пометок пользователя
if (searchInMarked)
q = q.Where(m => m.IsMarked);
var maxResults = Config.Instance.SearchConfig.MaxResultInSelect;
if (maxResults > 0)
q = q.Take(maxResults);
var msgTable = db.Messages();
var msgs =
q
.Select(
m =>
new LinearTreeMsg(provider)
{
ID = m.ID,
ForumID = m.ForumID,
TopicIDInternal = m.TopicID,
ParentID = m.ParentID,
Date = m.Date,
UserID = m.UserID,
UserNick = m.UserNick,
UserClass = (short)m.UserClass,
Subject = m.Subject,
IsRead = m.IsRead,
Rating = m.Rating(),
Smiles = m.SmileCount(),
Agrees = m.AgreeCount(),
Disagrees = m.DisagreeCount(),
RepliesCount = msgTable.Count(im => im.ParentID == m.ID),
});
var list =
msgs
.Cast<MsgBase>()
.ToList();
foreach (var msg in list)
msg.EndMapping();
return list;
}
}