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
| use DataBaseName | |
| go | |
| EXEC sp_MSforeachtable @command1 = "DROP TABLE ?" | |
| go |
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
| use ProjectCode | |
| insert into dbo.BlogPosts values(newid(),'Post1','Content1',CURRENT_TIMESTAMP,'F26D2321-FE49-472D-AE80-0FDECF0BF6BC') | |
| go | |
| insert into prices (group, id, price) | |
| select | |
| 7, articleId, 1.50 | |
| from article where name like 'ABC%'; |
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_help TableName; |
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
| shut down SQL Server from services | |
| open cmd window (as admin) and run single-user mode as local admin with this command | |
| c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Binn\sqlservr.exe" -m -s SQLEXPRESS | |
| open another cmd window (as admin) | |
| open sqlcmd |
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 ISessionFactory CreateSessionFactory() | |
| { | |
| //const string Connstring = "server=SWIGVA01-SRV341;database=LeafPoint_Global;" + | |
| // "User Id=lp_global;Password=lp_gl0b4l;"; | |
| const string Connstring = @"server=.\SQLEXPRESS;database=SimpleDB;" + | |
| "Integrated Security=SSPI;"; | |
| return Fluently.Configure() | |
| .Database(MsSqlConfiguration |
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
| const string Connstring = "server=SWIGVA01-SRV341;database=LeafPoint_Global;" + | |
| "User Id=user;Password=pwd;"; | |
| configuration= Fluently.Configure() | |
| .Database(MsSqlConfiguration | |
| .MsSql2008 | |
| .ConnectionString(Connstring).ShowSql()) | |
| .Mappings(m => m.FluentMappings | |
| .AddFromAssemblyOf<FunctionMap>() | |
| //.Conventions.Add(new PrimaryKeyNameConvention()) |
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
| var metadata = sf.GetAllClassMetadata().ToList(); | |
| IDictionary<string,IClassMetadata> data = sf.GetAllClassMetadata(); | |
| //Dictionary<string, SingleTableEntityPersister> lstTable = sf.GetAllClassMetadata().ToDictionary(x => x.Key, x=> x.Value); | |
| foreach (var table in metadata) | |
| { | |
| Console.WriteLine("List {0}", table.ToString()); | |
| } | |
| foreach(KeyValuePair<string,IClassMetadata> entry in data) | |
| { | |
| Console.WriteLine("Value {0} {1}",entry.Key,entry.Value.EntityName); |
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
| // Shows how to return a deep copy clone of an object. | |
| class CloneTest : ICloneable | |
| { | |
| public int SomeProperty { get; set; } | |
| public object Clone() | |
| { | |
| CloneTest clone = new CloneTest(); | |
| clone.SomeProperty = this.SomeProperty; |
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
| /// <summary> | |
| /// Returns the path (with ending backslash) of current executing assembly | |
| /// </summary> | |
| /// <returns>Path of executing assembly</returns> | |
| public static string AssemblyPath () { | |
| return Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location) + | |
| Path.DirectorySeparatorChar; | |
| } | |
| /// <summary> |
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 void ClearFolder(string FolderName) | |
| { | |
| DirectoryInfo dir = new DirectoryInfo(FolderName); | |
| foreach (FileInfo fi in dir.GetFiles()) | |
| { | |
| fi.IsReadOnly = false; | |
| fi.Delete(); | |
| } |