public void Test_Fill_Entity_With_Same_Property_Name() { using (var db = new TestDataContext().WithData()) { var query = db.Blogs .Where(b => b.BlogId == 1) .Select(b => new { UserName = "******", b.User }); var result = db.Query( query, new EFModelInfoProvider(db), new SqliteObjectFactory()); Assert.Equal("Ethan Li", result.Single().User.UserName); db.Database.CloseConnection(); } }
private static void UpdateData(TestDataContext db) { db.Database.OpenConnection(); db.Users.Add(new User { UserId = 1, UserName = "******" }); db.Users.Add(new User { UserId = 2, UserName = "******" }); db.Blogs.Add(new Blog { BlogId = 1, Url = "ethan1.com", UserId = 1 }); db.Blogs.Add(new Blog { BlogId = 2, Url = "ethan2.com", UserId = 1 }); db.Blogs.Add(new Blog { BlogId = 3, Url = "ethan3.com", UserId = 1 }); db.Blogs.Add(new Blog { BlogId = 4, Url = "xu1.com", UserId = 2 }); db.Blogs.Add(new Blog { BlogId = 5, Url = "xu2.com", UserId = 2 }); db.Posts.Add(new Post { PostId = 1, Content = "Post 1", Title = "Title 1", BlogId = 1, UserId = 1 }); db.Posts.Add(new Post { PostId = 2, Content = "Post 2", Title = "Title 2", BlogId = 1, UserId = 1 }); db.SaveChanges(); }