public void TestIncludeChildrenWithoutKey() { MapperConfig.HasKey <Parent>(x => x.Id); var query = Context.Query <Parent>() .Include(x => x.Children, x => x.ParentId, (p, c) => { p.Children = c.ToList(); foreach (var child in c) { child.Parent = p; } }); var parents = query.ToList(); foreach (var parent in parents) { Console.WriteLine(parent); } var pm = query.FirstOrDefault(); Console.WriteLine(pm); }
public void TestIncludeParentWithoutKey() { MapperConfig.HasKey <Parent>(x => x.Id); var query = Context.Query <Child>() .Include(x => x.Parent, x => x.ParentId, (c, p) => { c.Parent = p; if (p.Children == null) { p.Children = new List <Child>(); } p.Children.Add(c); }); var children = query.ToList(); foreach (var child in children) { Console.WriteLine(child); } var pm = query.FirstOrDefault(); Console.WriteLine(pm); }
public void Init() { MapperConfig.HasTableName <UserRole>("UserRoles"); MapperConfig.HasTableName <RoleFunction>("RoleActions"); MapperConfig.HasTableName <Role>("Roles"); MapperConfig.HasTableName <User>("Users"); MapperConfig.HasTableName <Function>("Actions"); MapperConfig.HasTableName <Menu>("Menus"); MapperConfig.HasTableName <SomeValues>("SomeValues"); MapperConfig.HasTableName <ModelMultiKeys>("TestModel"); MapperConfig.HasKey <UserRole>(x => x.Id); MapperConfig.HasKey <RoleFunction>(x => x.Id); MapperConfig.HasKey <Role>(x => x.Id); MapperConfig.HasKey <User>(x => x.Id); MapperConfig.HasKey <Function>(x => x.Id); MapperConfig.HasKey <Menu>(x => x.Id); MapperConfig.HasKey <SomeValues>(x => x.Id); MapperConfig.HasKey <ModelMultiKeys>(x => x.Name, x => x.Code); MapperConfig.HasColumnName <RoleFunction>(x => x.FunctionId, "ActionID"); MapperConfig.HasColumnName <User>(x => x.IsAdmin, "IsSys"); }