各个 ASP.NET 站点导航组件之间的关系图
而我们这次就是编程图中的"自定义站点地图提供程序"....
我的DAL层是基于NBear的....
Category实体定义如下:
[AutoPreLoad]
public interface Category : Entity
{
[PrimaryKey]
int ID { get; }
[SqlType("nvarchar(50)")]
string Title { get; set; }
/// <summary>
/// 排序位置
/// </summary>
int Sort { get;set;}
[FkReverseQuery(LazyLoad = true)]
[MappingName("ParentID")]
Category Parent { get;set;}
[FkQuery("Parent", LazyLoad = false, OrderBy= "Sort")]
[SerializationIgnore]
Category[] Children { get; set; }
[FkQuery("Category", OrderBy = "{ID} DESC", LazyLoad = true)]
Article[] Articles { get;set;}
}
public interface Category : Entity
{
[PrimaryKey]
int ID { get; }
[SqlType("nvarchar(50)")]
string Title { get; set; }
/// <summary>
/// 排序位置
/// </summary>
int Sort { get;set;}
[FkReverseQuery(LazyLoad = true)]
[MappingName("ParentID")]
Category Parent { get;set;}
[FkQuery("Parent", LazyLoad = false, OrderBy= "Sort")]
[SerializationIgnore]
Category[] Children { get; set; }
[FkQuery("Category", OrderBy = "{ID} DESC", LazyLoad = true)]
Article[] Articles { get;set;}
}
程序代码如下:
}
}
}
此SiteMapProvider只适合我的项目, 在此只是作个示例展示如何扩展StaticSiteMapProvider而已....