Releases: maliming/Abp.GeneralTree
Releases · maliming/Abp.GeneralTree
Update Abp to 5.1, support for net core 3.1!
Update Abp to 5.0, support for net core 3.0!
3.0.0 Update Abp to 5.0, support for net core 3.0!
2.4.2
Update Abp to 4.0.2
2.4.1 Update Abp to 4.0.2
There is a bug in v2.3.0 to v2.3.2, please download the latest version.
There is a bug in v2.3.0 to v2.3.2, please download the latest version.
Update Abp to 3.8.2
update Abp to 3.8.2
GeneralTreeExtensions ToTree Method Children Support Sorting.
[Fact]
public void ToTreeOrderBy_Test()
{
var regions = new List<Regin>
{
new Regin
{
Id = 1,
Name = "b北京"
},
new Regin
{
Id = 2,
Name = "b东城区",
ParentId = 1
},
new Regin
{
Id = 3,
Name = "a西城区",
ParentId = 1
},
new Regin
{
Id = 4,
Name = "a河北"
},
new Regin
{
Id = 5,
Name = "b石家庄",
ParentId = 4
},
new Regin
{
Id = 6,
Name = "a承德",
ParentId = 4
},
new Regin
{
Id = 7,
Name = "b双桥区",
ParentId = 6
},
new Regin
{
Id = 8,
Name = "a双滦区",
ParentId = 6
}
};
var tree = regions.ToTreeOrderBy<Regin, long, string>(x => x.Name).ToList();
tree.First().Name.ShouldBe("a河北");
tree.First().Children.First().Name.ShouldBe("a承德");
tree.First().Children.First().Children.First().Name.ShouldBe("a双滦区");
}
CodeGenerate supports configuring Code length.
[Fact]
public void Test_CreateCode_With_Length()
{
var generate = new GeneralTreeCodeGenerate(new GeneralTreeCodeGenerateConfiguration()
{
CodeLength = 3
});
generate.CreateCode().ShouldBe(null);
generate.CreateCode(42).ShouldBe("042");
generate.CreateCode(1, 2).ShouldBe("001.002");
generate.CreateCode(1, 2, 3).ShouldBe("001.002.003");
}
fix MoveAsync parentId null bug.
2.2.9 Release v2.2.9
add CheckSameNameExpression for special situations.
[Fact]
public async Task CheckSameNameExpression_Test()
{
var uowManager = LocalIocManager.Resolve<IUnitOfWorkManager>();
using (var uow = uowManager.Begin()) {
var repository = LocalIocManager.Resolve<IRepository<Region, long>>();
var config = new GeneralTreeConfiguration<Region, long>
{
CheckSameNameExpression = (regionThis, regionCheck) =>
regionThis.SomeForeignKey == regionCheck.SomeForeignKey
};
var manager =
new GeneralTreeManager<Region, long>(repository, config);
//Act
await manager.CreateAsync(new Region
{
Name = "beijing",
SomeForeignKey = 1
});
uowManager.Current.SaveChanges();
//Act
await manager.CreateAsync(new Region
{
Name = "beijing",
SomeForeignKey = 2
});
uowManager.Current.SaveChanges();
//Assert
var beijing1 = repository.FirstOrDefault(x => x.Name == "beijing" && x.SomeForeignKey == 1);
beijing1.ShouldNotBeNull();
var beijing2 = repository.FirstOrDefault(x => x.Name == "beijing" && x.SomeForeignKey == 2);
beijing2.ShouldNotBeNull();
uow.Complete();
}
}