public static CategoryCollection Top(int count, QueryFilter where, OrderBy <CategoryColumns> orderBy = null, Database database = null) { Database db = database ?? Db.For <Category>(); QuerySet query = GetQuerySet(db); query.Top <Category>(count); query.Where(where); if (orderBy != null) { query.OrderBy <CategoryColumns>(orderBy); } query.Execute(db); var results = query.Results.As <CategoryCollection>(0); results.Database = db; return(results); }
public static AssemblyDescriptorAssemblyReferenceDescriptorCollection Top(int count, QueryFilter where, OrderBy <AssemblyDescriptorAssemblyReferenceDescriptorColumns> orderBy = null, Database database = null) { Database db = database ?? Db.For <AssemblyDescriptorAssemblyReferenceDescriptor>(); QuerySet query = GetQuerySet(db); query.Top <AssemblyDescriptorAssemblyReferenceDescriptor>(count); query.Where(where); if (orderBy != null) { query.OrderBy <AssemblyDescriptorAssemblyReferenceDescriptorColumns>(orderBy); } query.Execute(db); var results = query.Results.As <AssemblyDescriptorAssemblyReferenceDescriptorCollection>(0); results.Database = db; return(results); }
public static ProtocolCollection Top(int count, QueryFilter where, string orderBy = null, SortOrder sortOrder = SortOrder.Ascending, Database database = null) { Database db = database ?? Db.For <Protocol>(); QuerySet query = GetQuerySet(db); query.Top <Protocol>(count); query.Where(where); if (orderBy != null) { query.OrderBy(orderBy, sortOrder); } query.Execute(db); var results = query.Results.As <ProtocolCollection>(0); results.Database = db; return(results); }
public void AlternativeSyntaxTest() { SqlClientRegistrar.Register <Item>(); Db.TryEnsureSchema <Item>(); Database db = Db.For(typeof(Item)); Item createdItem = new Item(); createdItem.Name = "Item_".RandomLetters(8); QuerySet query = new QuerySet(); query.Insert <Item>(createdItem); query.Select <Item>().Where <ItemColumns>(c => c.Name.StartsWith("I")); query.Count <Item>(); query.Execute(db); // alternative syntax //query.Insert<Item>(createdItem) // .Select<Item>().Where<ItemColumns>(c => c.Name.StartsWith("I")) // .Count<Item>() // .Execute(db); // -- end alternative syntax Item insertedItem = query.Results.ToDao <Item>(0); OutLineFormat("InsertedItemId: {0}, Name: {1}", ConsoleColor.Green, insertedItem.Id, insertedItem.Name); ItemCollection items = query.Results[1].As <ItemCollection>(); OutLine("** Item Results **", ConsoleColor.DarkYellow); items.Each(item => { OutLineFormat("Id: {0}, Name: {1}", ConsoleColor.DarkYellow, item.Id, item.Name); }); long count = query.Results[2].As <CountResult>().Value; OutLineFormat("Count Result: {0}", ConsoleColor.Yellow, count); }
public static WebHookDescriptorWebHookSubscriberCollection Top(int count, QueryFilter where, OrderBy <WebHookDescriptorWebHookSubscriberColumns> orderBy = null, Database database = null) { Database db = database ?? Db.For <WebHookDescriptorWebHookSubscriber>(); QuerySet query = GetQuerySet(db); query.Top <WebHookDescriptorWebHookSubscriber>(count); query.Where(where); if (orderBy != null) { query.OrderBy <WebHookDescriptorWebHookSubscriberColumns>(orderBy); } query.Execute(db); var results = query.Results.As <WebHookDescriptorWebHookSubscriberCollection>(0); results.Database = db; return(results); }
public static ServiceDescriptorCollection Top(int count, WhereDelegate<ServiceDescriptorColumns> where, OrderBy<ServiceDescriptorColumns> orderBy, Database database = null) { ServiceDescriptorColumns c = new ServiceDescriptorColumns(); IQueryFilter filter = where(c); Database db = database ?? Db.For<ServiceDescriptor>(); QuerySet query = GetQuerySet(db); query.Top<ServiceDescriptor>(count); query.Where(filter); if(orderBy != null) { query.OrderBy<ServiceDescriptorColumns>(orderBy); } query.Execute(db); var results = query.Results.As<ServiceDescriptorCollection>(0); results.Database = db; return results; }
public static TestSuiteDefinitionCollection Top(int count, WhereDelegate <TestSuiteDefinitionColumns> where, OrderBy <TestSuiteDefinitionColumns> orderBy, Database database = null) { TestSuiteDefinitionColumns c = new TestSuiteDefinitionColumns(); IQueryFilter filter = where (c); Database db = database ?? Db.For <TestSuiteDefinition>(); QuerySet query = GetQuerySet(db); query.Top <TestSuiteDefinition>(count); query.Where(filter); if (orderBy != null) { query.OrderBy <TestSuiteDefinitionColumns>(orderBy); } query.Execute(db); var results = query.Results.As <TestSuiteDefinitionCollection>(0); results.Database = db; return(results); }
public static DaoReferenceObjectWithForeignKeyCollection Top(int count, WhereDelegate <DaoReferenceObjectWithForeignKeyColumns> where, OrderBy <DaoReferenceObjectWithForeignKeyColumns> orderBy, Database database = null) { DaoReferenceObjectWithForeignKeyColumns c = new DaoReferenceObjectWithForeignKeyColumns(); IQueryFilter filter = where (c); Database db = database ?? Db.For <DaoReferenceObjectWithForeignKey>(); QuerySet query = GetQuerySet(db); query.Top <DaoReferenceObjectWithForeignKey>(count); query.Where(filter); if (orderBy != null) { query.OrderBy <DaoReferenceObjectWithForeignKeyColumns>(orderBy); } query.Execute(db); var results = query.Results.As <DaoReferenceObjectWithForeignKeyCollection>(0); results.Database = db; return(results); }
public static AssemblyDescriptorProcessRuntimeDescriptorCollection Top(int count, WhereDelegate <AssemblyDescriptorProcessRuntimeDescriptorColumns> where, OrderBy <AssemblyDescriptorProcessRuntimeDescriptorColumns> orderBy, Database database = null) { AssemblyDescriptorProcessRuntimeDescriptorColumns c = new AssemblyDescriptorProcessRuntimeDescriptorColumns(); IQueryFilter filter = where (c); Database db = database ?? Db.For <AssemblyDescriptorProcessRuntimeDescriptor>(); QuerySet query = GetQuerySet(db); query.Top <AssemblyDescriptorProcessRuntimeDescriptor>(count); query.Where(filter); if (orderBy != null) { query.OrderBy <AssemblyDescriptorProcessRuntimeDescriptorColumns>(orderBy); } query.Execute(db); var results = query.Results.As <AssemblyDescriptorProcessRuntimeDescriptorCollection>(0); results.Database = db; return(results); }
public static WebHookSubscriberCollection Top(int count, WhereDelegate <WebHookSubscriberColumns> where, OrderBy <WebHookSubscriberColumns> orderBy, Database database = null) { WebHookSubscriberColumns c = new WebHookSubscriberColumns(); IQueryFilter filter = where (c); Database db = database ?? Db.For <WebHookSubscriber>(); QuerySet query = GetQuerySet(db); query.Top <WebHookSubscriber>(count); query.Where(filter); if (orderBy != null) { query.OrderBy <WebHookSubscriberColumns>(orderBy); } query.Execute(db); var results = query.Results.As <WebHookSubscriberCollection>(0); results.Database = db; return(results); }
/// <summary> /// Execute a query and return the specified count /// of values /// </summary> /// <param name="count">The number of values to return. /// This value is used in the sql query so no more than this /// number of values will be returned by the database. /// </param> /// <param name="where">A WhereDelegate that recieves a ListItemColumns /// and returns a IQueryFilter which is the result of any comparisons /// between ListItemColumns and other values /// </param> /// <param name="orderBy"> /// Specifies what column and direction to order the results by /// </param> /// <param name="db"></param> public static ListItemCollection Top(int count, WhereDelegate <ListItemColumns> where, OrderBy <ListItemColumns> orderBy, Database database = null) { ListItemColumns c = new ListItemColumns(); IQueryFilter filter = where (c); Database db = database == null?Db.For <ListItem>() : database; QuerySet query = GetQuerySet(db); query.Top <ListItem>(count); query.Where(filter); if (orderBy != null) { query.OrderBy <ListItemColumns>(orderBy); } query.Execute(db); var results = query.Results.As <ListItemCollection>(0); results.Database = db; return(results); }