public void Test_Razor_Lits() { var runner = new Runner(); var data = new BlogView() { Id = 1, Posts = new List <BlogPost>() { new BlogPost() { Id = 5 }, new BlogPost() { Id = 12 }, } }; var model = Runnable.Command(data, separator: ","); model.M(p => p.Lit(m => m.Id)); model.Sql(";"); model.M(p => p.Open(m => m.Posts).Lit(m => m.Id)); model.Sql(";"); model.M(p => p.Vals(m => m.Posts).Skip(1).FirstOrDefault().Lit(m => m.Id)); var result = runner.Sql(model); result.ShouldBe("1;5;12"); }
public void Test_Razor_Model_Props() { var runner = new Runner(); var data = new BlogView() { Id = 1, Posts = new List <BlogPost>() { new BlogPost() { Id = 1 }, new BlogPost() { Id = 2, CreatedOn = DateTime.Now }, } }; var model = Runnable.Command(data, separator: ","); model.M(p => p.Prop(m => m.Id)); model.Sql(";"); model.M(p => p.Open(m => m.Posts).Prop(m => m.Id)); model.Sql(";"); model.M(p => p.Open(m => m.Posts).Prop(m => m.CreatedOn)); model.Sql(";"); model.M(p => p.Vals(m => m.Posts).Skip(1).FirstOrDefault().Prop(m => m.Id)); var result = runner.Sql(model); result.ShouldBe(@"""Model.Id"";""Model.Posts.Item[0].Id"";""Model.Posts.Item[0].CreatedOn"";""Model.Posts.Item[1].Id"""); }
public void Test_Razor_Pars() { var runner = new Runner(); var data = new BlogView() { Id = 1, Posts = new List <BlogPost>() { new BlogPost() { Id = 1 }, new BlogPost() { Id = 2, CreatedOn = DateTime.Now }, } }; var model = Runnable.Command(data, separator: ","); model.M(p => p.Par(m => m.Id)); model.Sql(";"); model.M(p => p.Open(m => m.Posts).Par(m => m.Id)); model.Sql(";"); model.M(p => p.Open(m => m.Posts).Par(m => m.CreatedOn)); model.Sql(";"); model.M(p => p.Vals(m => m.Posts).Skip(1).FirstOrDefault().Par(m => m.Id)); model.Sql(";"); model.M(p => p.Par(m => m.Id)); var result = runner.Sql(model); result.ShouldBe("@P0;@P1;@P2;@P3;@P0"); }