本文整理汇总了C#中IRepository.GetByQery方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.GetByQery方法的具体用法?C# IRepository.GetByQery怎么用?C# IRepository.GetByQery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRepository
的用法示例。
在下文中一共展示了IRepository.GetByQery方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DropFileInCategory
private void DropFileInCategory(object sender, DragEventArgs e)
{
ImageService imgService = new ImageService();
string[] fileList = e.Data.GetData(DataFormats.FileDrop) as string[];
string fileextension = Path.GetExtension(fileList[0]);
if (fileextension != ".pdf")
{
MessageBox.Show("Not allowed Drag'n'Drop for this file type");
}
else
{
string filename = Path.GetFileNameWithoutExtension(fileList[0]);
string pathtofile = Path.GetFullPath(fileList[0]);
string pathtobookimage = imgService.GenerateImage(pathtofile);
FileInfo fileToAdd = new FileInfo(pathtofile);
int size = (int)fileToAdd.Length;
var book = new Book()
{
Name = filename,
FileType = fileextension,
Path = pathtofile,
PathToBookImg = pathtobookimage,
Author = "Unknown Author",
Size = size
};
Debug.WriteLine(book.Name);
_categoriesRepository = IoCManager.Kernel.Get<IRepository<Category>>();
var concreteCategory = _categoriesRepository.GetByQery(q => q.Name == "Foreign Literature");
concreteCategory.FirstOrDefault().Books.Add(book);
_categoriesRepository.SaveChanges();
MessageBox.Show("Book was added");
}
}
示例2: GetBooks
private void GetBooks()
{
_bookRepository = IoCManager.Kernel.Get<IRepository<Book>>();
var favoriteBooks = _bookRepository.GetByQery(q => q.IsFavorite);
Books = new ObservableCollection<Book>(favoriteBooks);
}
示例3: GetBooks
private void GetBooks()
{
_bookRepository = IoCManager.Kernel.Get<IRepository<Book>>();
var readBooks = _bookRepository.GetByQery(q => q.IsRead);
Books = new ObservableCollection<Book>(readBooks);
}