当前位置: 首页>>代码示例>>C#>>正文


C# IDbConnection.Select方法代码示例

本文整理汇总了C#中IDbConnection.Select方法的典型用法代码示例。如果您正苦于以下问题:C# IDbConnection.Select方法的具体用法?C# IDbConnection.Select怎么用?C# IDbConnection.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDbConnection的用法示例。


在下文中一共展示了IDbConnection.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DbToWs

 public static LocationOfInterest DbToWs(this LocationOfInterestDB loiDB, IDbConnection db)
 {
     var loi = new LocationOfInterest();
     loi.LocationOfInterestID = loiDB.LocationOfInterestID;
     loi.LocationDescription = loiDB.LocationDescription;
     loi.DescriptionOfWork = loiDB.DescriptionOfWork;
     loi.Position = new Position();
     loi.Position.Latitutde = loiDB.PositionLatitutde;
     loi.Position.Longitude = loiDB.PositionLongitude;
     if (loiDB.PovHeading != null)
     {
         loi.POV = new PointOfView();
         loi.POV.Heading = loiDB.PovHeading.Value;
         loi.POV.Pitch = loiDB.PovPitch.Value;
     }
     loi.PanoID = loiDB.PanoID;
     loi.UploadedImageIDs = loiDB.UploadedImageIDs;
     var tyepOfWorkDB = db.Select<TypeOfWorkDB>(m => m.TypeOfWorkID == loiDB.TypeOfWorkID);
     loi.TypeOfWorkDescription = tyepOfWorkDB[0].Description;
     loi.StateCreated = loiDB.StateCreated;
     loi.StartDate = loiDB.StartDate;
     loi.StopDate = loiDB.StopDate;
     loi.CreatedOn = loiDB.CreatedOn;
     return(loi);
 }
开发者ID:sweatercomeback,项目名称:public-data-extravaganza,代码行数:25,代码来源:ModelExtensions.cs

示例2: InsertAndSelectDateTime

 private static DateTimeObject InsertAndSelectDateTime(IDbConnection db, DateTime dateTime)
 {
     db.DropAndCreateTable<DateTimeObject>();
     db.Insert(new DateTimeObject {Test = dateTime});
     var x = db.Select<DateTimeObject>().First();
     return x;
 }
开发者ID:yeurch,项目名称:ServiceStack.OrmLite,代码行数:7,代码来源:EnsureUtcTest.cs

示例3: Seed

        public static void Seed(IDbConnection db)
        {
            if (db.Select<Category>().Any()) return;

            db.InsertParam(new Category { Name = "Support", Colour = "" });
            db.InsertParam(new Category { Name = "Project", Colour = "" });
            db.InsertParam(new Category { Name = "Maintainance", Colour = "#ffa500" });
            db.InsertParam(new Category { Name = "Sales", Colour = "#f0f0f0" });
        }
开发者ID:TheFailBoat,项目名称:IssueTracker,代码行数:9,代码来源:CategorySeeder.cs

示例4: Seed

        public static void Seed(IDbConnection db)
        {
            if (db.Select<Priority>().Any()) return;

            db.InsertParam(new Priority { Name = "Low", Colour = "#3bb9ff", Order = 0 });
            db.InsertParam(new Priority { Name = "Normal", Colour = "", Order = 1 });
            db.InsertParam(new Priority { Name = "High", Colour = "#f88017", Order = 2 });
            db.InsertParam(new Priority { Name = "Urgent", Colour = "#800517", Order = 3 });
            db.InsertParam(new Priority { Name = "Immediate", Colour = "#ff0080", Order = 4 });
        }
开发者ID:TheFailBoat,项目名称:IssueTracker,代码行数:10,代码来源:PrioritySeeder.cs

示例5: Run

        protected override void Run(IDbConnection db)
		{
			if (this.IsFirstRun)
			{
				db.CreateTable<SampleOrderLine>(true);
				db.Insert(SampleOrderLine.Create(userId, this.Iteration, 1));
			}

			var row = db.Select<SampleOrderLine>();
		}
开发者ID:yeurch,项目名称:ServiceStack.OrmLite,代码行数:10,代码来源:InsertSampleOrderLineScenario.cs

示例6: Run

        protected override void Run(IDbConnection db)
		{
			if (this.IsFirstRun)
			{
				db.CreateTable<ModelWithFieldsOfDifferentTypesPerf>(true);
				20.Times(i => db.Insert(ModelWithFieldsOfDifferentTypesPerf.Create(i)));
			}

			var rows = db.Select<ModelWithFieldsOfDifferentTypesPerf>();
		}
开发者ID:CormacBrennan-AI,项目名称:ServiceStack.OrmLite,代码行数:10,代码来源:InsertModelWithFieldsOfDifferentTypesScenario.cs

示例7: Seed

        public static void Seed(IDbConnection db)
        {
            if (db.Select<Status>().Any()) return;

            db.InsertParam(new Status { Name = "New", Colour = "", IsClosed = false, Order = 1 });
            db.InsertParam(new Status { Name = "Scheduled", Colour = "", IsClosed = false, Order = 2 });
            db.InsertParam(new Status { Name = "In Progress", Colour = "", IsClosed = false, Order = 3 });
            db.InsertParam(new Status { Name = "Waiting for Feedback", Colour = "", IsClosed = false, Order = 4 });
            db.InsertParam(new Status { Name = "Resolved", Colour = "", IsClosed = true, Order = 5 });
            db.InsertParam(new Status { Name = "Closed", Colour = "", IsClosed = true, Order = 6 });
            db.InsertParam(new Status { Name = "Rejected", Colour = "", IsClosed = true, Order = 7 });
        }
开发者ID:TheFailBoat,项目名称:IssueTracker,代码行数:12,代码来源:StatusSeeder.cs

示例8: GetBasicSearchResults

        public IEnumerable<LayerSearchResult> GetBasicSearchResults(string searchPhrase, IDbConnection dbConn)
        {
            List<LayersCmsPage> pages = dbConn.Select<LayersCmsPage>(page => (page.PageTitle.Contains(searchPhrase)
                                                                                    ||
                                                                                    page.MetaDescription.Contains(searchPhrase)
                                                                                    ||
                                                                                    page.MetaKeywords.Contains(searchPhrase)
                                                                                    ||
                                                                                    page.WindowTitle.Contains(searchPhrase)
                                                                                    ||
                                                                                    page.Content.Contains(searchPhrase)
                                                                                    ));

            return pages.Where(p => p.IsPublished).Select(p => new LayerSearchResult()
                {
                    Description = p.MetaDescription,
                    ImageUrl = null,
                    Name = p.PageTitle,
                    Url = p.Url
                });
        }
开发者ID:stevekennaird,项目名称:LayersCMS,代码行数:21,代码来源:CmsPageSearchableLayer.cs

示例9: GetUserGroups

 /// <summary>
 /// Get user group IDs that user can access.
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="userGroupId"></param>
 /// <returns></returns>
 static public long[] GetUserGroups(IDbConnection Db, long userId)
 {
     string query = "SELECT " + GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroup>(Db) +".* FROM " + GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroup>(Db);
     query += "INNER JOIN " + GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroupUser>(Db) +  " ON " + GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroupUser>(Db) + ".UserGroupID = " + GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroup>(Db) + ".ID ";
     query += string.Format("WHERE " + GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroup>(Db) + ".Removed IS NULL AND " + GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroupUser>(Db) + ".Removed IS NULL AND UserID = {0}", userId);
     var rows = Db.Select<GXAmiUserGroup>(query);
     return rows.ConvertAll(x => x.Id).ToArray();
 }
开发者ID:jomolinare,项目名称:GuruxAMI.Server,代码行数:14,代码来源:GXUserGroupService.cs

示例10: JoinPackets

 byte[] JoinPackets(IDbConnection Db, ulong templateId)
 {
     List<GXAmiDeviceProfilesDataBlock> list = Db.Select<GXAmiDeviceProfilesDataBlock>(q => q.DeviceProfilesId == templateId);
     List<byte> data = new List<byte>();
     foreach (GXAmiDeviceProfilesDataBlock it in list)
     {
         data.AddRange(it.Data);
     }
     return data.ToArray();
 }
开发者ID:jomolinare,项目名称:GuruxAMI.Server,代码行数:10,代码来源:GXDeviceProfilesService.cs

示例11: CanAccess

 /// <summary>
 /// Can user access uuser group.
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="userGroupId"></param>
 /// <returns></returns>
 static public bool CanAccess(IDbConnection Db, long userId, long userGroupId)
 {
     string query = "SELECT UserGroupID FROM " + GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroupUser>(Db);
     query += string.Format("WHERE UserID = {0} AND UserGroupID = {1}", userId, userGroupId);
     return Db.Select<GXAmiUserGroup>(query).Count == 1;
 }
开发者ID:jomolinare,项目名称:GuruxAMI.Server,代码行数:12,代码来源:GXUserGroupService.cs

示例12: Run

        /// <summary>Runs the given database.</summary>
        /// <param name="dbCmd">The database.</param>
        protected override void Run(IDbConnection dbCmd)
		{
			if (this.IsFirstRun)
			{
				new InsertNorthwindDataScenario().InsertData(dbCmd);
			}

			dbCmd.Select<Category>();
			dbCmd.Select<Customer>();
			dbCmd.Select<Employee>();
			dbCmd.Select<Shipper>();
			dbCmd.Select<Order>();
			dbCmd.Select<Product>();
			dbCmd.Select<OrderDetail>();
			dbCmd.Select<CustomerCustomerDemo>();
			dbCmd.Select<Region>();
			dbCmd.Select<Territory>();
			dbCmd.Select<EmployeeTerritory>();
		}
开发者ID:sami1971,项目名称:NServiceKit.OrmLite,代码行数:21,代码来源:SelectNorthwindDataScenario.cs

示例13: GetDeviceProfiles

        List<GXAmiDeviceProfile> GetDeviceProfiles(IAuthSession s, IDbConnection Db, long userId, long userGroupId, bool? preset, string protocol, bool removed)
        {
            lock (Db)
            {
                string id = s.Id;
                bool admin = GuruxAMI.Server.GXBasicAuthProvider.IsSuperAdmin(s);
                List<string> Filter = new List<string>();
                string query = "SELECT * FROM " + GuruxAMI.Server.AppHost.GetTableName<GXAmiDeviceProfile>(Db) + " ";
                if (!admin || userGroupId != 0 || userId != 0)
                {
                    string tmp = "INNER JOIN {1} ON {0}.ID = {1}.DeviceProfilesID ";
                    tmp += "INNER JOIN {2} ON {1}.UserGroupID = {2}.ID ";
                    tmp += "INNER JOIN {3} ON {2}.ID = {3}.UserGroupID ";
                    query += string.Format(tmp,
                        GuruxAMI.Server.AppHost.GetTableName<GXAmiDeviceProfile>(Db),
                        GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroupDeviceProfile>(Db),
                        GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroup>(Db),
                        GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroupUser>(Db));

                    if (!removed)
                    {
                        Filter.Add(string.Format("{0}.Removed IS NULL",
                            GuruxAMI.Server.AppHost.GetTableName<GXAmiDeviceProfile>(Db)));
                    }
                    Filter.Add(string.Format("{0}.Removed IS NULL AND {1}.Removed IS NULL",
                            GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroup>(Db),
                            GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroupUser>(Db)));
                    if (userId != 0)
                    {
                        Filter.Add("UserID = " + userId.ToString());
                    }
                    else if (!admin)
                    {
                        Filter.Add("UserID = " + id.ToString());
                    }
                    if (userGroupId != 0)
                    {
                        Filter.Add("UserGroupID = " + userGroupId.ToString());
                    }
                }
                else if (!removed)
                {
                    Filter.Add("Removed IS NULL");
                }

                if (preset != null)
                {
                    bool value = preset.Value;
                    if (value)
                    {
                        Filter.Add("PresetName IS NOT NULL");
                    }
                    else
                    {
                        Filter.Add("PresetName IS NULL");
                    }
                }
                if (!string.IsNullOrEmpty(protocol))
                {
                    Filter.Add("Protocol = " + protocol);
                }
                if (Filter.Count != 0)
                {
                    query += "WHERE ";
                    query += string.Join(" AND ", Filter.ToArray());
                }
                return Db.Select<GXAmiDeviceProfile>(query);
            }
        }
开发者ID:jomolinare,项目名称:GuruxAMI.Server,代码行数:69,代码来源:GXDeviceProfilesService.cs

示例14: GetClaims

 public static IEnumerable<Claim> GetClaims(User user, IDbConnection connection)
 {
     return connection.Select<Claim>(c => c.UserId == user.Id);
 }
开发者ID:WildGenie,项目名称:Bastet-Legacy,代码行数:4,代码来源:Identity.cs

示例15: InsertAndSelectDateTime

 private static DateTimeObject InsertAndSelectDateTime(IDbConnection db, DateTime dateTime)
 {
     db.DeleteAll<DateTimeObject>();
     db.Insert(new DateTimeObject { Test = dateTime, TestNullable = dateTime });
     var x = db.Select<DateTimeObject>().First();
     return x;
 }
开发者ID:netProgrammer,项目名称:ServiceStack.OrmLite,代码行数:7,代码来源:DateTimeTests.cs


注:本文中的IDbConnection.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。