本文整理汇总了C#中IUnitOfWork.FindAll方法的典型用法代码示例。如果您正苦于以下问题:C# IUnitOfWork.FindAll方法的具体用法?C# IUnitOfWork.FindAll怎么用?C# IUnitOfWork.FindAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUnitOfWork
的用法示例。
在下文中一共展示了IUnitOfWork.FindAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateCodeId
public static string GenerateCodeId(string codeTypeId, IUnitOfWork context)
{
var codeIds = context.FindAll<Code>().Where(c => c.CodeTypeId == codeTypeId).OrderBy(f => f.CodeId).Select(ci => ci.CodeId).ToList();
var lastCodeId = codeIds.Count > 0 ? codeIds.Last() : null;
var IdCharCount = lastCodeId != null ? lastCodeId.Count() - 1 : 9;
List<char> chars = codeTypeId.ToList();
var charArray = chars.ToArray();
var numberId = 0;
if (lastCodeId != null)
{
numberId = int.Parse(lastCodeId.TrimStart(charArray));
if (lastCodeId[3].ToString(CultureInfo.InvariantCulture) == "1")
{
numberId++;
}
}
var newId = codeTypeId + numberId.ToString(CultureInfo.InvariantCulture);
var charCount = (codeTypeId + numberId.ToString(CultureInfo.InvariantCulture)).Count();
if (charCount < IdCharCount)
{
newId = string.Format(codeTypeId + '1' + new string('0', IdCharCount - charCount) + numberId.ToString(CultureInfo.InvariantCulture));
}
return newId;
}
示例2: GeneratePartyId
public static string GeneratePartyId(string partyTypeId, IUnitOfWork context, List<Party> currentParties)
{
var partyIds = context.FindAll<Party>().Where(p => p.PartyTypeId == partyTypeId).OrderBy(f => f.PartyId).Select(pi => pi.PartyId).ToList();
var lastPartyId = partyIds.Count > 0 ? partyIds.Last() : null;
var IdCharCount = lastPartyId != null ? lastPartyId.Count() - 1 : 9;
List<char> chars = partyTypeId.ToList();
var charArray = chars.ToArray();
var numberId = 0;
if (lastPartyId != null)
{
numberId = int.Parse(lastPartyId.TrimStart(charArray));
if (lastPartyId[3].ToString(CultureInfo.InvariantCulture) == "1")
{
numberId++;
}
}
var newId = partyTypeId + numberId.ToString(CultureInfo.InvariantCulture);
var charCount = (partyTypeId + numberId.ToString(CultureInfo.InvariantCulture)).Count();
if (charCount < IdCharCount)
{
newId = string.Format(partyTypeId + '1' + new string('0', IdCharCount - charCount) + numberId.ToString(CultureInfo.InvariantCulture));
}
if (currentParties.Any())
{
var currentPartyIds = currentParties.Select(p => p.PartyId).ToList();
while (currentPartyIds.Contains(newId))
{
numberId++;
newId = partyTypeId + numberId.ToString(CultureInfo.InvariantCulture);
if (charCount < IdCharCount)
{
newId = string.Format(partyTypeId + '1' + new string('0', IdCharCount - charCount) + numberId.ToString(CultureInfo.InvariantCulture));
}
}
}
return newId;
}