public bool CompileAndRun(Simple.Data.Database database, out object output) { var code = MakeCode(); var compiled = Compile(code); if (compiled.Errors.HasErrors) { output = ReturnErrors(compiled); return(false); } output = ReturnOutput(compiled, database); return(true); }
private static void SetupSelectSingleTest(List <Test> tests) { const string TestName = "SelectSingle"; // add dapper tests.Add( new Test( Providers.Dapper, TestName, i => { using (var dapperConn = connectionFactory.OpenDbConnection()) { return (dapperConn.Query <Post>( "select [PostId], [Title], [Content], [Rating], [AuthorId], [BlogId], [DoNotMap] from [Posts] where ([PostId] = @l_1)", new { l_1 = i }).First()); } })); // add Dashing tests.Add( new Test( Providers.Dashing, TestName, i => { using (var dashingSession = dashingConfig.BeginSession()) { return(dashingSession.Query <Post>().First(p => p.PostId == i)); } })); // dashing - no transaction tests.Add( new Test( Providers.Dashing, TestName, i => { using (var dashingSession = dashingConfig.BeginTransactionLessSession()) { return(dashingSession.Get <Post>(i)); } }, "By Id without Transaction")); // add Dashing by id tests.Add( new Test( Providers.Dashing, TestName, i => { using (var dashingSession = dashingConfig.BeginSession()) { return(dashingSession.Get <Post>(i)); } }, "By Id")); // add ef tests.Add( new Test( Providers.EntityFramework, TestName, i => { using (var EfDb = new EfContext()) { return(EfDb.Posts.AsNoTracking().First(p => p.PostId == i)); } })); // add ef2 tests.Add( new Test( Providers.EntityFramework, TestName, i => { using (var EfDb = new EfContext()) { EfDb.Configuration.AutoDetectChangesEnabled = false; var post = EfDb.Posts.Find(i); EfDb.Configuration.AutoDetectChangesEnabled = true; return(post); } }, "Using Find with AutoDetectChangesEnabled = false")); // add ormlite tests.Add( new Test( Providers.ServiceStack, TestName, i => { using (var ormliteConn = connectionFactory.Open()) { using (ormliteConn.OpenTransaction()) { return(ormliteConn.SingleById <Post>(i)); } } })); // add ormlite tests.Add( new Test( Providers.ServiceStack, TestName, i => { using (var ormliteConn = connectionFactory.Open()) { return(ormliteConn.SingleById <Post>(i)); } }, "Without transaction")); // add simple data tests.Add( new Test( Providers.SimpleData, TestName, i => { var simpleDataDb = Database.OpenConnection(ConnectionString.ConnectionString); return(simpleDataDb.Posts.Get(i)); })); // add nh stateless tests.Add( new Test( Providers.NHibernate, TestName, i => { using (var nhStatelessSession = Nh.SessionFactory.OpenStatelessSession()) { return(nhStatelessSession.Get <Post>(i)); } }, "Stateless")); // add nh stateful tests.Add( new Test( Providers.NHibernate, TestName, i => { using (var nhSession = Nh.SessionFactory.OpenSession()) { return(nhSession.Get <Post>(i)); } }, "Stateful")); // add lightspeed tests.Add( new Test( Providers.LightSpeed, TestName, i => { using (var uow = lsContext.CreateUnitOfWork()) { return(uow.Posts.Single(p => p.Id == i)); } }, "Linq")); // lightspeed find by id tests.Add( new Test( Providers.LightSpeed, TestName, i => { using (var uow = lsContext.CreateUnitOfWork()) { return(uow.FindById <LightSpeed.Domain.Post>(i)); } }, "FindById without transaction")); }