This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// disable select cast(serverproperty('EngineEdition') as int) | |
/// <summary> | |
/// DbConfiguration | |
/// </summary> | |
public class CustomConfiguration : DbConfiguration | |
{ | |
public CustomConfiguration() | |
{ | |
SetDatabaseInitializer<DbContext>(null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
var ret1 = ServiceFactory.BaseInfoService.Instance.GetData(15); | |
ServiceFactory.BaseInfoService.SetClientContext(new ClientContext(332, 13)); | |
var ret2 = ServiceFactory.BaseInfoService.Instance.GetData(1055); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GenericCollection<T> : ICollection<T> | |
{ | |
private readonly HashSet<T> _set; | |
public IEnumerator<T> GetEnumerator() | |
{ | |
return _set.GetEnumerator(); | |
} | |
IEnumerator IEnumerable.GetEnumerator() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class DbMigrationExtensions | |
{ | |
public static void AlterDataFileSize(this DbMigration dbMigration, int size) | |
{ | |
var sqlMethod = dbMigration.GetType().GetMethod("Sql", BindingFlags.Instance | BindingFlags.NonPublic); | |
sqlMethod.Invoke(dbMigration, new object[] { $@" | |
DECLARE @dbName varchar(100) = (SELECT db_name()) | |
DECLARE @sqlCommand nvarchar(1000) = ('ALTER DATABASE ' + @dbName + ' MODIFY FILE ( NAME = ''' + @dbName +''', SIZE = {size}MB )') | |
EXECUTE sp_executesql @sqlCommand, N'@dbName varchar(100)', @dbName = @dbName | |
", true, null }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
namespace SocialGoal.Data.Infrastructure | |
{ | |
public class Page | |
{ | |
public int PageNumber { get; set; } | |
public int PageSize { get; set; } | |
public Page() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EXEC sp_resetstatus [YourDatabase]; | |
ALTER DATABASE [YourDatabase] SET EMERGENCY | |
DBCC checkdb([YourDatabase]) | |
ALTER DATABASE [YourDatabase] SET SINGLE_USER WITH ROLLBACK IMMEDIATE | |
DBCC CheckDB ([YourDatabase], REPAIR_ALLOW_DATA_LOSS) | |
ALTER DATABASE [YourDatabase] SET MULTI_USER |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Running & Scripting Migrations From Code | |
//https://romiller.com/2012/02/09/running-scripting-migrations-from-code/ | |
var configuration = new MyContextConfiguration(); | |
var migrator = new DbMigrator(configuration); | |
var scriptor = new MigratorScriptingDecorator(migrator); | |
string script = scriptor.ScriptUpdate(sourceMigration: null, targetMigration: null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class IsolatedStorageController | |
{ | |
private static readonly JsonSerializer Serializer; | |
private static readonly IsolatedStorageScope Scope; | |
private static readonly Type DomainEvidenceType; | |
private static readonly Type AssemblyEvidenceType; | |
static IsolatedStorageController() | |
{ | |
Serializer = new JsonSerializer(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Flags()] | |
internal enum SetupDiGetClassDevsFlags | |
{ | |
Default = 1, | |
Present = 2, | |
AllClasses = 4, | |
Profile = 8, | |
DeviceInterface = (int)0x10 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void Main(string[] args) | |
{ | |
ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Keyboard"); | |
var devs = managementObjectSearcher.Get(); | |
foreach (var o in devs) | |
{ | |
var dev = (ManagementObject) o; | |
Console.WriteLine("-----------------------------------------------------"); | |
Console.WriteLine(dev["Name"].ToString()); |