本文整理汇总了C#中System.Data.SqlClient.SqlConnection.Select方法的典型用法代码示例。如果您正苦于以下问题:C# SqlConnection.Select方法的具体用法?C# SqlConnection.Select怎么用?C# SqlConnection.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlConnection
的用法示例。
在下文中一共展示了SqlConnection.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResumeCase
public bool ResumeCase(string caseId, string taskName, object value)
{
using (var connection = new SqlConnection(_connectionString))
{
try
{
connection.Open();
SqlDataReader reader =
connection.Select(BookmarkTableName,
new KeyValuePair<string, object>(CaseIdColumnName, caseId));
using (reader)
{
reader.Read();
Guid instanceId = Guid.Parse((string) reader[WorkflowinstanceidColumnName]);
var resetEvent = new ManualResetEvent(false);
WorkflowApplication wfApp = GetWorkflowApplication(new CaseWorkflow(), caseId, resetEvent);
lock (this)
{
wfApp.Load(instanceId);
BookmarkResumptionResult result = wfApp.ResumeBookmark(taskName, value);
resetEvent.WaitOne(TimeSpan.FromMinutes(1));
return result == BookmarkResumptionResult.Success;
}
}
}
catch (Exception e)
{
return false;
}
}
}
示例2: GetUsersByRole
public IEnumerable<User> GetUsersByRole(Role role)
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
var users = new List<User>();
var reader = connection.Select(_tableName, new KeyValuePair<string, object>("Role", role.ToString()));
while (reader.Read())
users.Add(ExtractUser(reader));
reader.Close();
return users;
}
}
示例3: GetCaseById
public Case? GetCaseById(string caseId)
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
SqlDataReader reader = connection.Select(CaseTableName,
new KeyValuePair<string, object>("编号", caseId));
using (reader)
{
if (reader.Read())
return ExtractCase(reader);
return null;
}
}
}
示例4: GetAllCustomers
public IEnumerable<Customer> GetAllCustomers()
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
List<Customer> customers;
using (SqlDataReader reader = connection.Select(CustomerTableName))
{
customers = new List<Customer>();
while (reader.Read())
customers.Add(ExtractCustomer(reader));
}
return customers;
}
}
示例5: GetCustomer
public Customer? GetCustomer(string 客户号)
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
SqlDataReader reader = connection.Select(CustomerTableName,
new KeyValuePair<string, object>("客户号", 客户号));
using (reader)
{
if (reader.Read())
return ExtractCustomer(reader);
return null;
}
}
}
示例6: Login
public Tuple<LoginResult, User> Login(string userName, string password)
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
LoginResult result;
User user = null;
SqlDataReader reader = connection.Select(_tableName, new KeyValuePair<string, object>("UserName", userName));
if (reader.Read())
if ((string) reader["Password"] != password)
result = LoginResult.PasswordNotMatch;
else
{
result = LoginResult.Successful;
user = ExtractUser(reader);
}
else
result = LoginResult.UserNotExist;
return Tuple.Create(result, user);
}
}
示例7: GetDocsOf
public IEnumerable<CaseDoc> GetDocsOf(string 案件编号)
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
SqlDataReader reader = connection.Select(CaseDocTableName,
new KeyValuePair<string, object>("案件编号", 案件编号));
List<CaseDoc> caseDocs;
using (reader)
{
caseDocs = new List<CaseDoc>();
while (reader.Read())
caseDocs.Add(new CaseDoc
{
FileName = (string) reader["文件名"],
UploadUserName = (string) reader["创建人"],
UploadDateTime = (DateTime) reader["创建日期"],
FilePath = (string) reader["文件路径"]
});
}
return caseDocs;
}
}
示例8: GetMessagesOf
public IEnumerable<CaseMessage> GetMessagesOf(string 案件编号)
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
SqlDataReader reader = connection.Select(TableName, new KeyValuePair<string, object>("案件编号", 案件编号));
List<CaseMessage> caseMessages;
using (reader)
{
caseMessages = new List<CaseMessage>();
while (reader.Read())
{
caseMessages.Add(new CaseMessage
{
案件编号 = (string) reader["案件编号"],
Content = (string) reader["Content"],
SenderUsername = (string) reader["SenderName"]
});
}
}
return caseMessages;
}
}
示例9: GetActivities
public IList<Activity> GetActivities()
{
IList<Activity> activities;
IList<ActivityActivity> activityActivities;
using (var conn = new SqlConnection(ConnectionString))
{
activities = conn.Select<Activity>().ToList();
activityActivities = conn.Select<ActivityActivity>().ToList();
}
var groups = activityActivities.OrderBy(a => a.ActivityId).GroupBy(a => a.ParentActivityId);
foreach (var group in groups)
{
var parentActivity = activities.SingleOrDefault(a => a.Id == group.Key);
if (parentActivity == null)
{
continue;
}
foreach (var child in group)
{
var childActivity = activities.SingleOrDefault(a => a.Id == child.ActivityId);
if (childActivity != null)
{
parentActivity.Activities.Add(childActivity);
}
}
}
return activities;
}
示例10: GetInventor
public Inventor? GetInventor(string 身份证号)
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
SqlDataReader reader = connection.Select(InventorTableName,
new KeyValuePair<string, object>("身份证号", 身份证号));
using (reader)
{
if (reader.Read())
return ExtractInventor(reader);
return null;
}
}
}
示例11: GetAllInventors
public IEnumerable<Inventor> GetAllInventors()
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
var inventors = new List<Inventor>();
using (SqlDataReader sqlDataReader = connection.Select(InventorTableName))
while (sqlDataReader.Read())
inventors.Add(ExtractInventor(sqlDataReader));
return inventors;
}
}
示例12: GetApplicant
public Applicant? GetApplicant(string 证件号)
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
SqlDataReader reader = connection.Select(ApplicantTableName,
new KeyValuePair<string, object>("证件号", 证件号));
using (reader)
{
if (reader.Read())
return ExtractApplicant(reader);
return null;
}
}
}
示例13: GetAllApplicants
public IEnumerable<Applicant> GetAllApplicants()
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
var applicants = new List<Applicant>();
using (SqlDataReader reader = connection.Select(ApplicantTableName))
while (reader.Read())
applicants.Add(ExtractApplicant(reader));
return applicants;
}
}
示例14: GetCustomerContacts
public IEnumerable<CustomerContact> GetCustomerContacts(string 客户号)
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
var customerContacts = new List<CustomerContact>();
SqlDataReader reader = connection.Select(CustomerContactTableName,
new KeyValuePair<string, object>("客户号", 客户号));
using (reader)
{
while (reader.Read())
customerContacts.Add(ExtractCustomerContact(reader));
}
return customerContacts;
}
}
示例15: GetRoles
public IList<Role> GetRoles(IList<Activity> activities)
{
IList<Role> roles;
IList<RoleRole> roleRoles;
IList<RoleActivity> roleActivities;
using (var conn = new SqlConnection(ConnectionString))
{
roles = conn.Select<Role>().ToList();
roleRoles = conn.Select<RoleRole>().ToList();
roleActivities = conn.Select<RoleActivity>().ToList();
}
var roleActivityGroups = roleActivities.OrderBy(r => r.ActivityId).GroupBy(r => r.RoleId);
foreach (var group in roleActivityGroups)
{
var role = roles.SingleOrDefault(r => r.Id.Equals(group.Key));
if (role == null)
{
continue;
}
foreach (var activity in group)
{
var childActivity = activities.SingleOrDefault(a => a.Id == activity.ActivityId);
if (childActivity != null)
{
role.Activities.Add(childActivity);
}
}
}
var groups = roleRoles.OrderBy(r => r.RoleId).GroupBy(r => r.ParentRoleId);
foreach (var group in groups)
{
var parentRole = roles.SingleOrDefault(r => r.Id == group.Key);
if (parentRole == null)
{
continue;
}
foreach (var child in group)
{
var childRole = roles.SingleOrDefault(r => r.Id == child.RoleId);
if (childRole != null)
{
parentRole.Roles.Add(childRole);
}
}
}
return roles;
}