本文整理汇总了C#中IDbConnection.SqlScalar方法的典型用法代码示例。如果您正苦于以下问题:C# IDbConnection.SqlScalar方法的具体用法?C# IDbConnection.SqlScalar怎么用?C# IDbConnection.SqlScalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDbConnection
的用法示例。
在下文中一共展示了IDbConnection.SqlScalar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanUserAccessDevice
/// <summary>
/// Can user access device.
/// </summary>
/// <param name="userId"></param>
/// <param name="DeviceGroupId"></param>
/// <returns></returns>
static public bool CanUserAccessDevice(IDbConnection Db, long userId, ulong deviceId)
{
string query = "SELECT COUNT(*) FROM {0}";
query += "INNER JOIN {1} ON {0}.ID = {1}.DeviceID ";
query += "INNER JOIN {2} ON {1}.DeviceGroupID = {2}.ID ";
query += "INNER JOIN {3} ON {2}.ID = {3}.DeviceGroupID ";
query += "INNER JOIN {4} ON {3}.UserGroupID = {4}.ID ";
query += "INNER JOIN {5} ON {4}.ID = {5}.UserGroupID ";
query = string.Format(query,
GuruxAMI.Server.AppHost.GetTableName<GXAmiDevice>(Db),
GuruxAMI.Server.AppHost.GetTableName<GXAmiDeviceGroupDevice>(Db),
GuruxAMI.Server.AppHost.GetTableName<GXAmiDeviceGroup>(Db),
GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroupDeviceGroup>(Db),
GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroup>(Db),
GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroupUser>(Db));
query += string.Format("WHERE {0}.Removed IS NULL AND {1}.Removed IS NULL AND {2}.Removed IS NULL AND {3}.Removed IS NULL AND {4}.UserID = {5} AND {0}.ID = {6}",
GuruxAMI.Server.AppHost.GetTableName<GXAmiDevice>(Db),
GuruxAMI.Server.AppHost.GetTableName<GXAmiDeviceGroup>(Db),
GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroupDeviceGroup>(Db),
GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroup>(Db),
GuruxAMI.Server.AppHost.GetTableName<GXAmiUserGroupUser>(Db),
userId, deviceId);
return Db.SqlScalar<long>(query, null) != 0;
}
示例2: CanDataCollectorsAccessDevice
static public bool CanDataCollectorsAccessDevice(IDbConnection Db, ulong deviceId, Guid dataCollectorGuid)
{
List<GXAmiDataCollector> list = Db.Select<GXAmiDataCollector>(p => p.Guid == dataCollectorGuid);
if (list.Count != 1)
{
return false;
}
string query = string.Format("SELECT COUNT(*) FROM {0} WHERE Disabled = FALSE AND DeviceID = {1} AND (DataCollectorId = {2} OR DataCollectorId IS NULL)",
GuruxAMI.Server.AppHost.GetTableName<GXAmiDeviceMedia>(Db),
deviceId,
list[0].Id);
return Db.SqlScalar<long>(query, null) != 0;
}