Created
December 10, 2010 12:57
-
-
Save Itslet/736172 to your computer and use it in GitHub Desktop.
Piece of Global.asax.cs for Eloquera
This file contains 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 MvcApplication : NinjectHttpApplication | |
{ | |
public static DB db = new DB("server=(local);password=;options=none;"); | |
private static void openSession() | |
{ | |
if (File.Exists(@"c:\temp\db\iSay.eq")) { | |
db.OpenDatabase("iSay"); | |
db.RegisterType(typeof(iSay.Story)); | |
db.RegisterType(typeof(iSay.Comment)); | |
} else { | |
db.CreateDatabase("iSay"); | |
db.OpenDatabase("iSay"); | |
db.RegisterType(typeof(iSay.Story)); | |
db.RegisterType(typeof(iSay.Comment)); | |
//add some dummy data | |
Story s = new Story { | |
StoryHeader = "Just another iSay weblog!", | |
StoryText = "Today I am so awesome.", | |
PostDate = DateTime.Now | |
}; | |
Comment c = new Comment { | |
CommentText = "Oh really.", | |
PostDate = DateTime.Now, | |
PostedBy = "The Lousy Commenter", | |
Story = s | |
}; | |
Comment c1 = new Comment | |
{ | |
CommentText = "I totally agree", | |
PostDate = DateTime.Now, | |
PostedBy = "The Sweet Commenter", | |
Story = s | |
}; | |
var comments = new List<Comment>(); | |
comments.Add(c); | |
comments.Add(c1); | |
s.Comments = comments; | |
db.Store(s); | |
db.Store(c); | |
db.Store(c1); | |
db.Close(); | |
openSession(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment