本文整理汇总了C#中Microsoft.Data.SQLite.SQLiteParameter类的典型用法代码示例。如果您正苦于以下问题:C# SQLiteParameter类的具体用法?C# SQLiteParameter怎么用?C# SQLiteParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLiteParameter类属于Microsoft.Data.SQLite命名空间,在下文中一共展示了SQLiteParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public bool Update(
Guid guid,
Guid siteGuid,
string folderName)
{
StringBuilder sqlCommand = new StringBuilder();
sqlCommand.Append("UPDATE mp_SiteFolders ");
sqlCommand.Append("SET ");
sqlCommand.Append("SiteGuid = :SiteGuid, ");
sqlCommand.Append("FolderName = :FolderName ");
sqlCommand.Append("WHERE ");
sqlCommand.Append("Guid = :Guid ;");
SQLiteParameter[] arParams = new SQLiteParameter[3];
arParams[0] = new SQLiteParameter(":Guid", DbType.String);
arParams[0].Value = guid.ToString();
arParams[1] = new SQLiteParameter(":SiteGuid", DbType.String);
arParams[1].Value = siteGuid.ToString();
arParams[2] = new SQLiteParameter(":FolderName", DbType.String);
arParams[2].Value = folderName;
int rowsAffected = AdoHelper.ExecuteNonQuery(
connectionString,
sqlCommand.ToString(),
arParams);
return (rowsAffected > -1);
}
示例2: Ctor_sets_name_and_value
public void Ctor_sets_name_and_value()
{
var result = new SQLiteParameter("@Parameter", 1);
Assert.Equal("@Parameter", result.ParameterName);
Assert.Equal(1, result.Value);
}
示例3: GetUserCountByYearMonth
public DbDataReader GetUserCountByYearMonth(int siteId)
{
StringBuilder sqlCommand = new StringBuilder();
sqlCommand.Append("SELECT ");
sqlCommand.Append("strftime('%Y', DateCreated) AS Y, ");
sqlCommand.Append("strftime('%m', DateCreated) AS M, ");
sqlCommand.Append("strftime('%Y', DateCreated) + '-' + strftime('%m', DateCreated) AS Label, ");
sqlCommand.Append("COUNT(*) As Users ");
sqlCommand.Append("FROM ");
sqlCommand.Append("mp_Users ");
sqlCommand.Append("WHERE ");
sqlCommand.Append("SiteID = :SiteID ");
sqlCommand.Append("GROUP BY strftime('%Y', DateCreated), strftime('%m', DateCreated) ");
sqlCommand.Append("ORDER BY strftime('%Y', DateCreated), strftime('%m', DateCreated) ");
sqlCommand.Append("; ");
SQLiteParameter[] arParams = new SQLiteParameter[1];
arParams[0] = new SQLiteParameter(":SiteID", DbType.Int32);
arParams[0].Value = siteId;
return AdoHelper.ExecuteReader(
connectionString,
sqlCommand.ToString(),
arParams);
}
示例4: Add
public bool Add(
Guid guid,
Guid siteGuid,
string folderName)
{
StringBuilder sqlCommand = new StringBuilder();
sqlCommand.Append("INSERT INTO mp_SiteFolders (");
sqlCommand.Append("Guid, ");
sqlCommand.Append("SiteGuid, ");
sqlCommand.Append("FolderName )");
sqlCommand.Append(" VALUES (");
sqlCommand.Append(":Guid, ");
sqlCommand.Append(":SiteGuid, ");
sqlCommand.Append(":FolderName );");
SQLiteParameter[] arParams = new SQLiteParameter[3];
arParams[0] = new SQLiteParameter(":Guid", DbType.String);
arParams[0].Value = guid.ToString();
arParams[1] = new SQLiteParameter(":SiteGuid", DbType.String);
arParams[1].Value = siteGuid.ToString();
arParams[2] = new SQLiteParameter(":FolderName", DbType.String);
arParams[2].Value = folderName;
int rowsAffected = AdoHelper.ExecuteNonQuery(
connectionString,
sqlCommand.ToString(),
arParams);
return rowsAffected > 0;
}
示例5: GetSiteSettingsExList
public DbDataReader GetSiteSettingsExList(int siteId)
{
StringBuilder sqlCommand = new StringBuilder();
sqlCommand.Append("SELECT e.* ");
sqlCommand.Append("FROM mp_SiteSettingsEx e ");
sqlCommand.Append("JOIN ");
sqlCommand.Append("mp_SiteSettingsExDef d ");
sqlCommand.Append("ON ");
sqlCommand.Append("e.KeyName = d.KeyName ");
sqlCommand.Append("AND e.GroupName = d.GroupName ");
sqlCommand.Append("WHERE ");
sqlCommand.Append("e.SiteID = :SiteID ");
sqlCommand.Append("ORDER BY d.GroupName, d.SortOrder ");
sqlCommand.Append(";");
SQLiteParameter[] arParams = new SQLiteParameter[1];
arParams[0] = new SQLiteParameter(":SiteID", DbType.Int32);
arParams[0].Value = siteId;
return AdoHelper.ExecuteReader(
connectionString,
sqlCommand.ToString(),
arParams);
}
示例6: Create
public bool Create(
int siteId,
string loginProvider,
string providerKey,
string providerDisplayName,
string userId)
{
StringBuilder sqlCommand = new StringBuilder();
sqlCommand.Append("INSERT INTO mp_UserLogins (");
sqlCommand.Append("LoginProvider ,");
sqlCommand.Append("ProviderKey, ");
sqlCommand.Append("UserId, ");
sqlCommand.Append("SiteId, ");
sqlCommand.Append("ProviderDisplayName ");
sqlCommand.Append(") ");
sqlCommand.Append("VALUES (");
sqlCommand.Append(":LoginProvider, ");
sqlCommand.Append(":ProviderKey, ");
sqlCommand.Append(":UserId, ");
sqlCommand.Append(":SiteId, ");
sqlCommand.Append(":ProviderDisplayName ");
sqlCommand.Append(")");
sqlCommand.Append(";");
SQLiteParameter[] arParams = new SQLiteParameter[5];
arParams[0] = new SQLiteParameter(":LoginProvider", DbType.String);
arParams[0].Value = loginProvider;
arParams[1] = new SQLiteParameter(":ProviderKey", DbType.String);
arParams[1].Value = providerKey;
arParams[2] = new SQLiteParameter(":UserId", DbType.String);
arParams[2].Value = userId;
arParams[3] = new SQLiteParameter(":SiteId", DbType.Int32);
arParams[3].Value = siteId;
arParams[4] = new SQLiteParameter(":ProviderDisplayName", DbType.String);
arParams[4].Value = providerDisplayName;
int rowsAffected = AdoHelper.ExecuteNonQuery(
connectionString,
sqlCommand.ToString(),
arParams);
return (rowsAffected > -1);
}
示例7: GetUserList
public DbDataReader GetUserList(int siteId)
{
StringBuilder sqlCommand = new StringBuilder();
sqlCommand.Append("SELECT UserID, Name, PasswordSalt, Pwd, Email FROM mp_Users WHERE SiteID = :SiteID ORDER BY Email");
SQLiteParameter[] arParams = new SQLiteParameter[1];
arParams[0] = new SQLiteParameter(":SiteID", DbType.Int32);
arParams[0].Value = siteId;
return AdoHelper.ExecuteReader(
connectionString,
sqlCommand.ToString(),
arParams);
}
示例8: RoleCreate
public int RoleCreate(
Guid roleGuid,
Guid siteGuid,
int siteId,
string roleName)
{
StringBuilder sqlCommand = new StringBuilder();
sqlCommand.Append("INSERT INTO mp_Roles (");
sqlCommand.Append("SiteID, ");
sqlCommand.Append("RoleName, ");
sqlCommand.Append("DisplayName, ");
sqlCommand.Append("SiteGuid, ");
sqlCommand.Append("RoleGuid )");
sqlCommand.Append(" VALUES (");
sqlCommand.Append(":SiteID, ");
sqlCommand.Append(":RoleName, ");
sqlCommand.Append(":RoleName, ");
sqlCommand.Append(":SiteGuid, ");
sqlCommand.Append(":RoleGuid )");
sqlCommand.Append(";");
sqlCommand.Append("SELECT LAST_INSERT_ROWID();");
SQLiteParameter[] arParams = new SQLiteParameter[4];
arParams[0] = new SQLiteParameter(":SiteID", DbType.Int32);
arParams[0].Value = siteId;
arParams[1] = new SQLiteParameter(":RoleName", DbType.String);
arParams[1].Value = roleName;
arParams[2] = new SQLiteParameter(":SiteGuid", DbType.String);
arParams[2].Value = siteGuid.ToString();
arParams[3] = new SQLiteParameter(":RoleGuid", DbType.String);
arParams[3].Value = roleGuid.ToString();
int newID = Convert.ToInt32(AdoHelper.ExecuteScalar(
connectionString,
sqlCommand.ToString(),
arParams).ToString());
return newID;
}
示例9: Create
public int Create(
int siteId,
string userId,
string claimType,
string claimValue)
{
StringBuilder sqlCommand = new StringBuilder();
sqlCommand.Append("INSERT INTO mp_UserClaims (");
sqlCommand.Append("SiteId, ");
sqlCommand.Append("UserId, ");
sqlCommand.Append("ClaimType, ");
sqlCommand.Append("ClaimValue )");
sqlCommand.Append(" VALUES (");
sqlCommand.Append(":SiteId, ");
sqlCommand.Append(":UserId, ");
sqlCommand.Append(":ClaimType, ");
sqlCommand.Append(":ClaimValue )");
sqlCommand.Append(";");
sqlCommand.Append("SELECT LAST_INSERT_ROWID();");
SQLiteParameter[] arParams = new SQLiteParameter[4];
arParams[0] = new SQLiteParameter(":UserId", DbType.String);
arParams[0].Value = userId;
arParams[1] = new SQLiteParameter(":ClaimType", DbType.Object);
arParams[1].Value = claimType;
arParams[2] = new SQLiteParameter(":ClaimValue", DbType.Object);
arParams[2].Value = claimValue;
arParams[3] = new SQLiteParameter(":SiteId", DbType.Int32);
arParams[3].Value = siteId;
int newID = Convert.ToInt32(AdoHelper.ExecuteScalar(
connectionString,
sqlCommand.ToString(),
arParams).ToString());
return newID;
}
示例10: Create
/// <summary>
/// Inserts a row in the mp_GeoCountry table. Returns rows affected count.
/// </summary>
/// <param name="guid"> guid </param>
/// <param name="name"> name </param>
/// <param name="iSOCode2"> iSOCode2 </param>
/// <param name="iSOCode3"> iSOCode3 </param>
/// <returns>bool</returns>
public bool Create(
Guid guid,
string name,
string iSOCode2,
string iSOCode3)
{
StringBuilder sqlCommand = new StringBuilder();
sqlCommand.Append("INSERT INTO mp_GeoCountry (");
sqlCommand.Append("Guid, ");
sqlCommand.Append("Name, ");
sqlCommand.Append("ISOCode2, ");
sqlCommand.Append("ISOCode3 )");
sqlCommand.Append(" VALUES (");
sqlCommand.Append(":Guid, ");
sqlCommand.Append(":Name, ");
sqlCommand.Append(":ISOCode2, ");
sqlCommand.Append(":ISOCode3 )");
sqlCommand.Append(";");
SQLiteParameter[] arParams = new SQLiteParameter[4];
arParams[0] = new SQLiteParameter(":Guid", DbType.String);
arParams[0].Value = guid.ToString();
arParams[1] = new SQLiteParameter(":Name", DbType.String);
arParams[1].Value = name;
arParams[2] = new SQLiteParameter(":ISOCode2", DbType.String);
arParams[2].Value = iSOCode2;
arParams[3] = new SQLiteParameter(":ISOCode3", DbType.String);
arParams[3].Value = iSOCode3;
int rowsAffected = AdoHelper.ExecuteNonQuery(
connectionString,
sqlCommand.ToString(),
arParams);
return rowsAffected > 0;
}
示例11: Create
/// <summary>
/// Inserts a row in the mp_Language table. Returns rows affected count.
/// </summary>
/// <param name="guid"> guid </param>
/// <param name="name"> name </param>
/// <param name="code"> code </param>
/// <param name="sort"> sort </param>
/// <returns>bool</returns>
public bool Create(
Guid guid,
string name,
string code,
int sort)
{
StringBuilder sqlCommand = new StringBuilder();
sqlCommand.Append("INSERT INTO mp_Language (");
sqlCommand.Append("Guid, ");
sqlCommand.Append("Name, ");
sqlCommand.Append("Code, ");
sqlCommand.Append("Sort )");
sqlCommand.Append(" VALUES (");
sqlCommand.Append(":Guid, ");
sqlCommand.Append(":Name, ");
sqlCommand.Append(":Code, ");
sqlCommand.Append(":Sort )");
sqlCommand.Append(";");
SQLiteParameter[] arParams = new SQLiteParameter[4];
arParams[0] = new SQLiteParameter(":Guid", DbType.String);
arParams[0].Value = guid.ToString();
arParams[1] = new SQLiteParameter(":Name", DbType.String);
arParams[1].Value = name;
arParams[2] = new SQLiteParameter(":Code", DbType.String);
arParams[2].Value = code;
arParams[3] = new SQLiteParameter(":Sort", DbType.Int32);
arParams[3].Value = sort;
int rowsAffected = AdoHelper.ExecuteNonQuery(
connectionString,
sqlCommand.ToString(),
arParams);
return rowsAffected > 0;
}
示例12: Add
/// <summary>
/// Inserts a row in the mp_BannedIPAddresses table. Returns new integer id.
/// </summary>
/// <param name="bannedIP"> bannedIP </param>
/// <param name="bannedUTC"> bannedUTC </param>
/// <param name="bannedReason"> bannedReason </param>
/// <returns>int</returns>
public int Add(
string bannedIP,
DateTime bannedUtc,
string bannedReason)
{
StringBuilder sqlCommand = new StringBuilder();
sqlCommand.Append("INSERT INTO mp_BannedIPAddresses (");
sqlCommand.Append("BannedIP, ");
sqlCommand.Append("BannedUTC, ");
sqlCommand.Append("BannedReason )");
sqlCommand.Append(" VALUES (");
sqlCommand.Append(":BannedIP, ");
sqlCommand.Append(":BannedUTC, ");
sqlCommand.Append(":BannedReason );");
sqlCommand.Append("SELECT LAST_INSERT_ROWID();");
SQLiteParameter[] arParams = new SQLiteParameter[3];
arParams[0] = new SQLiteParameter(":BannedIP", DbType.String);
arParams[0].Value = bannedIP;
arParams[1] = new SQLiteParameter(":BannedUTC", DbType.DateTime);
arParams[1].Value = bannedUtc;
arParams[2] = new SQLiteParameter(":BannedReason", DbType.String);
arParams[2].Value = bannedReason;
int newID = Convert.ToInt32(AdoHelper.ExecuteScalar(
connectionString,
sqlCommand.ToString(),
arParams).ToString());
return newID;
}
示例13: GetSiteIdByFolder
public int GetSiteIdByFolder(string folderName)
{
int siteId = -1;
StringBuilder sqlCommand = new StringBuilder();
SQLiteParameter[] arParams = new SQLiteParameter[1];
arParams[0] = new SQLiteParameter(":FolderName", DbType.String);
arParams[0].Value = folderName;
sqlCommand.Append("SELECT COALESCE(s.SiteID, -1) As SiteID ");
sqlCommand.Append("FROM mp_SiteFolders sf ");
sqlCommand.Append("JOIN mp_Sites s ");
sqlCommand.Append("ON ");
sqlCommand.Append("sf.SiteGuid = s.SiteGuid ");
sqlCommand.Append("WHERE sf.FolderName = :FolderName ");
sqlCommand.Append("ORDER BY s.SiteID ");
sqlCommand.Append(";");
using (DbDataReader reader = AdoHelper.ExecuteReader(
connectionString,
sqlCommand.ToString(),
arParams))
{
if (reader.Read())
{
siteId = Convert.ToInt32(reader["SiteID"]);
}
}
if (siteId == -1)
{
sqlCommand = new StringBuilder();
sqlCommand.Append("SELECT SiteID ");
sqlCommand.Append("FROM mp_Sites ");
sqlCommand.Append("ORDER BY SiteID ");
sqlCommand.Append("LIMIT 1 ;");
using (DbDataReader reader = AdoHelper.ExecuteReader(
connectionString,
sqlCommand.ToString(),
null))
{
if (reader.Read())
{
siteId = Convert.ToInt32(reader["SiteID"]);
}
}
}
return siteId;
}
示例14: GetSiteIdByHostName
public int GetSiteIdByHostName(string hostName)
{
int siteId = -1;
StringBuilder sqlCommand = new StringBuilder();
SQLiteParameter[] arParams = new SQLiteParameter[1];
arParams[0] = new SQLiteParameter(":HostName", DbType.String);
arParams[0].Value = hostName;
sqlCommand.Append("SELECT mp_SiteHosts.SiteID As SiteID ");
sqlCommand.Append("FROM mp_SiteHosts ");
sqlCommand.Append("WHERE mp_SiteHosts.HostName = :HostName ;");
using (DbDataReader reader = AdoHelper.ExecuteReader(
connectionString,
sqlCommand.ToString(),
arParams))
{
if (reader.Read())
{
siteId = Convert.ToInt32(reader["SiteID"]);
}
}
if (siteId == -1)
{
sqlCommand = new StringBuilder();
sqlCommand.Append("SELECT SiteID ");
sqlCommand.Append("FROM mp_Sites ");
sqlCommand.Append("ORDER BY SiteID ");
sqlCommand.Append("LIMIT 1 ;");
using (DbDataReader reader = AdoHelper.ExecuteReader(
connectionString,
sqlCommand.ToString(),
null))
{
if (reader.Read())
{
siteId = Convert.ToInt32(reader["SiteID"]);
}
}
}
return siteId;
}
示例15: GetPageOfOtherSites
public DbDataReader GetPageOfOtherSites(
int currentSiteId,
int pageNumber,
int pageSize)
{
int pageLowerBound = (pageSize * pageNumber) - pageSize;
StringBuilder sqlCommand = new StringBuilder();
sqlCommand.Append("SELECT * ");
sqlCommand.Append("FROM mp_Sites ");
sqlCommand.Append("WHERE SiteID <> :CurrentSiteID ");
sqlCommand.Append("ORDER BY ");
sqlCommand.Append("SiteName ");
sqlCommand.Append("LIMIT :PageSize ");
if (pageNumber > 1)
{
sqlCommand.Append("OFFSET :OffsetRows ");
}
sqlCommand.Append(";");
SQLiteParameter[] arParams = new SQLiteParameter[3];
arParams[0] = new SQLiteParameter(":CurrentSiteID", DbType.Int32);
arParams[0].Value = currentSiteId;
arParams[1] = new SQLiteParameter(":PageSize", DbType.Int32);
arParams[1].Value = pageSize;
arParams[2] = new SQLiteParameter(":OffsetRows", DbType.Int32);
arParams[2].Value = pageLowerBound;
return AdoHelper.ExecuteReader(
connectionString,
sqlCommand.ToString(),
arParams);
}