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


C# IDbConnection.Where方法代码示例

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


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

示例1: AddTextGroup

        private void AddTextGroup(IDbConnection db, int[] textGroups, int ProfileId)
        {
            try
            {
                var imagerecords = db.Where<ProfileTextGroup>("ProfileID", ProfileId);
                imagerecords.ForEach(x =>
                {
                    db.DeleteById<ProfileTextGroup>(x.Id);

                });
                if (textGroups != null)
                {
                    foreach (int item in textGroups)
                    {
                        ProfileTextGroup pig = new ProfileTextGroup();
                        pig.GroupID = item;
                        pig.ProfileID = ProfileId;
                        db.Insert<ProfileTextGroup>(pig);
                    }
                }

            }
            catch (Exception)
            {

                throw;
            }
        }
开发者ID:riskypathak,项目名称:Poster,代码行数:28,代码来源:ProfileController.cs

示例2: DasModule

        public DasModule()
        {
            Get["/", runAsync: true] = async (_, token) =>
            {
                var model = new MainModel()
                {
                    Title = Utilities.GetTitle(),
                    SubTitle = Utilities.GetSubTitle(),
                    TwitterWidgetSrc = Utilities.GetWidgetSrc(),
                    Users = GetList().Where(u=> u.Status != "Offline").Select(u => new DasUserEx(u)).OrderByDescending(o => o.Date)
                };

                return View["index.sshtml", model];
            };

            Get["/test"] = _ =>
            {
                return "Hello World";
            };

            Get["/new"] = _ =>
            {
                int ret = default(int);
                using (_connection = Utilities.GetOpenConnection())
                {
                    _connection.DropAndCreateTable<DasUser>();
                    _connection.Close();
                }

                return ret;
            };

            Get["/sample"] = _ =>
            {
                dynamic ret;
                using (_connection = Utilities.GetOpenConnection())
                {
                    ret = _connection.Insert(
                        new DasUser
                        {
                            TwitterId = 123456789,
                            Status = "Online",
                            Name = "테스터",
                            Message = "메세지메세지",
                            Date = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, DasModule.koreaTZI)
                        });
                    _connection.Close();
                }

                return ret;
            };

            Get["/delete"] = _ =>
            {
                int ret = default(int);
                using (_connection = Utilities.GetOpenConnection())
                {
                    var results = _connection.Where<DasUser>(new { TwitterId = 123456789 });
                    foreach (var result in results)
                    {
                        ret = _connection.Delete(result);
                    }
                    _connection.Close();
                }

                return ret;
            };
        }
开发者ID:JonghoL,项目名称:DasStaus,代码行数:68,代码来源:DasModule.cs

示例3: DeleteGroupFolder

 private void DeleteGroupFolder(IDbConnection db, int id)
 {
     var selectedGroup = db.Where<Group>("Id", id).FirstOrDefault();
     string groupName = selectedGroup.Name.Trim();
     string type = selectedGroup.Type;
     if (type == "img")
     {
         string groupPath = Server.MapPath("~/UploadImage/" + groupName);
         if (Directory.Exists(groupPath))
             Directory.Delete(groupPath, true);
     }
     else if (type == "txt")
     {
         string groupPath = Server.MapPath("~/UploadText/" + groupName);
         if (Directory.Exists(groupPath))
             Directory.Delete(groupPath, true);
     }
 }
开发者ID:riskypathak,项目名称:Poster,代码行数:18,代码来源:BulkImportController.cs

示例4: Answers

        private List<Answer> Answers(Question question, IDbConnection db)
        {
            if (null == question)
                return new List<Answer>();

            return db.Where<Answer>(a => a.QuestionId == question.Id).OrderBy(a => a.Order).ThenBy(a => a.Id).ToList();
        }
开发者ID:hross,项目名称:linkedin-survey,代码行数:7,代码来源:QuestionService.cs

示例5: PostText

        private string PostText(Profile objprofile, IDbConnection db)
        {
            var textGroups = db.Where<ProfileTextGroup>("ProfileID", objprofile.Id).Select(x => x.GroupID).ToList();
            string text = string.Empty;
            int group = 0;
            if (textGroups.Count > 0)
            {
                if (textGroups.Count > 1)
                {
                    group = rand.Next(textGroups.Count);
                }
                else
                {
                    group = 0;
                }

                var textList = db.Where<PostText>("GroupId", textGroups[group]).ToList();
                string file = string.Empty;
                if (textList.Count > 0)
                {
                    int number = rand.Next(textList.Count);
                    string path = textList[number].Text;
                    file = baseurl + path.Substring(3, path.Length - 3);
                    Log.WriteLog("text file:" + file);
                    string destination = Path.GetTempPath() + Guid.NewGuid() + ".txt";
                    using (WebClient webClient = new WebClient())
                    {
                        webClient.DownloadFile(file, destination);
                    }
                    text = System.IO.File.ReadAllText(destination);
                    Log.WriteLog("text file:" + destination);
                    File.Delete(destination);
                }
            }
            return text;
        }
开发者ID:riskypathak,项目名称:Poster,代码行数:36,代码来源:Service1.cs

示例6: PostImage

        private string PostImage(Profile objprofile, IDbConnection db)
        {
            Log.WriteLog("ID:"+objprofile.Id.ToString());
            var imageGroups = db.Where<ProfileImageGroup>("ProfileID", objprofile.Id).Select(x => x.GroupID).ToList();
            Log.WriteLog(imageGroups.Count.ToString());
            string file = string.Empty;
            int group = 0;
            if (imageGroups.Count > 0)
            {
                if (imageGroups.Count > 1)
                {
                    group = rand.Next(imageGroups.Count);
                }
                else
                {
                    group = 0;
                }

                var photoList = db.Where<PostImage>("GroupId", imageGroups[group]).ToList();

                if (photoList.Count > 0)
                {
                    int number = rand.Next(photoList.Count);
                    string path = photoList[number].Imagelink;
                    file = baseurl + path.Substring(3, path.Length - 3);
                }
            }
            return file;
        }
开发者ID:riskypathak,项目名称:Poster,代码行数:29,代码来源:Service1.cs


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