public async Task OnGetAsync(string?search, string?toDoActionReset) { if (toDoActionReset == "Reset") { Search = ""; } else { if (!string.IsNullOrWhiteSpace(search)) { Search = search.ToLower().Trim(); } } var bookQuery = _context.Books .Include(b => b.Language) .Include(b => b.Publisher) .Include(b => b.BookAuthors) .ThenInclude(a => a.Author) .Select(a => new BookIndexDto() { Book = a, CommentCount = 0, // a.Comments.Count LastComment = "" //a.Comments.LastOrDefault().CommentText }) .AsQueryable(); if (!string.IsNullOrWhiteSpace(Search)) { bookQuery = bookQuery .Where(b => b.Book !.Title.ToLower().Contains(Search) || b.Book.Publisher !.PublisherName.ToLower().Contains(Search) || b.Book.Comments.Any(c => c.CommentText.ToLower().Contains(Search)) || b.Book.BookAuthors.Any(d => d.Author !.FirstName.ToLower().Contains(Search) || d.Author.LastName.ToLower().Contains(Search) || (d.Author.FirstName + " " + d.Author.LastName).ToLower().Contains(Search) || (d.Author.LastName + " " + d.Author.FirstName).ToLower().Contains(Search)) ); } bookQuery = bookQuery.OrderBy(b => b.Book !.Title); Books = await bookQuery.ToListAsync(); foreach (var book in Books) { book.CommentCount = await _context.Comments.Where(c => c.BookId == book.Book !.BookId).CountAsync(); book.LastComment = ( await _context.Comments .Where(c => c.BookId == book.Book !.BookId) .OrderByDescending(c => c.CommentId).FirstOrDefaultAsync())?.CommentText; } }
public override int GetHashCode() { int hash = 1; if (Topic.Length != 0) { hash ^= Topic.GetHashCode(); } if (PublisherName.Length != 0) { hash ^= PublisherName.GetHashCode(); } hash ^= data_.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { unchecked { var hashCode = (Authors1 != null? Authors1.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Title != null? Title.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Authors2 != null? Authors2.GetHashCode() : 0); hashCode = (hashCode * 397) ^ HasOtherAuthors.GetHashCode(); hashCode = (hashCode * 397) ^ (Editor != null? Editor.GetHashCode() : 0); hashCode = (hashCode * 397) ^ HasOtherEditors.GetHashCode(); hashCode = (hashCode * 397) ^ Edition.GetHashCode(); hashCode = (hashCode * 397) ^ (PublisherCity != null? PublisherCity.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (PublisherName != null? PublisherName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ PublisherYear.GetHashCode(); hashCode = (hashCode * 397) ^ Pages.GetHashCode(); hashCode = (hashCode * 397) ^ PageStart.GetHashCode(); hashCode = (hashCode * 397) ^ PageEnd.GetHashCode(); hashCode = (hashCode * 397) ^ Number.GetHashCode(); return(hashCode); } }
public void Save() { bool needSave = false; if (SortMainId > 0) { var o = SortMainObject.GetSortMain(SortMainId); if (o != null) { if (PublisherName?.Trim() != o.PublisherName) { o.PublisherName = PublisherName?.Trim(); needSave = true; } if (PublisherCity?.Trim() != o.PublisherCity) { o.PublisherCity = PublisherCity?.Trim(); needSave = true; } if (PublisherState?.Trim() != o.PublisherState) { o.PublisherState = PublisherState?.Trim(); needSave = true; } if (PublisherCountry != o.PublisherCountry) { o.PublisherCountry = PublisherCountry; needSave = true; } if (needSave) { o.Save(); } } } }
private static string[] GenerateCode() { //Declare it TypeDeclaration d = new TypeDeclaration.Builder() .SetAccessModifier(AccessModifier.PUBLIC) .SetIsStatic(true) .SetInheritance(Inheritance.DEFAULT) .SetScope(Scope.CLASS) .SetName(ExtensionName.RemoveSpecialCharacters()) .Build(); //Import regularly used namespaces, just call a Using(...) if you need more UsingNode un = new UsingNode() .Using("UnityEngine") .Using("System.Collections") .Using("System.Collections.Generic") .Using("UnityEditor"); //Import the base class namespace to simplify its name in the declaration string if (d.baseClass != null) { un.Using(d.baseClass.Namespace); } //The same for interfaces if (d.implementedInterface.HasElement()) { for (int i = 0; i < d.implementedInterface.Count; ++i) { un.Using(d.implementedInterface[i].Namespace); } } //Give it a hint to determine type names TypeAlias.SetUsingNode(un); List <string> code = new List <string>(); //add basic function for an extension code.Add(GetExtensionNameCode()); code.Add(GetPublisherNameCode()); code.Add(GetDescriptionCode()); code.Add(GetVersionCode()); code.Add(GetOpenUserGuideCode()); code.Add(GetOpenSupportLinkCode()); code.Add(GetButtonMethodCode()); code.Add(GetOnGUICode()); //Implement the type TypeNode tn = new TypeNode() .Declare(d) .Implement(code); //Put the new type into the namespace NamespaceNode nn = new NamespaceNode() .SetName(string.Format("{0}.GriffinExtension", PublisherName.RemoveSpecialCharacters())) .SetTypes(tn); //Put everything into a script ScriptNode sn = new ScriptNode() .SetCompilationDirective("GRIFFIN && UNITY_EDITOR") .SetUsing(un) .SetNamespace(nn) .SetTypes(tn); //also set type in case namespace is empty //Now make the code look awesome CodeFormatter formatter = new CodeFormatter(); formatter.addSpaceAfterUsings = true; formatter.addSpaceBetweenMethods = true; formatter.bracketStyle = CodeFormatter.OpenCurlyBracketStyle.NewLine; string[] script = formatter.Format(sn); return(script); //phew... }