本文整理汇总了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;
}
}
示例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;
};
}
示例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);
}
}
示例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();
}
示例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;
}
示例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;
}