mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 01:05:27 +08:00 
			
		
		
		
	- 增加 CodeFirst 实体类注释 -> 表备注,之前只能属性注释 -> 字段备注;
This commit is contained in:
		@@ -400,11 +400,19 @@ namespace FreeSql.Internal
 | 
			
		||||
                }
 | 
			
		||||
                var xmlNav = xpath.CreateNavigator();
 | 
			
		||||
 | 
			
		||||
                var className = (type.IsNested ? $"{type.Namespace}.{type.DeclaringType.Name}.{type.Name}" : $"{type.Namespace}.{type.Name}").Trim('.');
 | 
			
		||||
                var node = xmlNav.SelectSingleNode($"/doc/members/member[@name='T:{className}']/summary");
 | 
			
		||||
                if (node != null)
 | 
			
		||||
                {
 | 
			
		||||
                    var comment = node.InnerXml.Trim(' ', '\r', '\n', '\t');
 | 
			
		||||
                    if (string.IsNullOrEmpty(comment) == false) dic.Add("", comment); //class注释
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                var props = type.GetPropertiesDictIgnoreCase().Values;
 | 
			
		||||
                foreach (var prop in props)
 | 
			
		||||
                {
 | 
			
		||||
                    var className = (prop.DeclaringType.IsNested ? $"{prop.DeclaringType.Namespace}.{prop.DeclaringType.DeclaringType.Name}.{prop.DeclaringType.Name}" : $"{prop.DeclaringType.Namespace}.{prop.DeclaringType.Name}").Trim('.');
 | 
			
		||||
                    var node = xmlNav.SelectSingleNode($"/doc/members/member[@name='P:{className}.{prop.Name}']/summary");
 | 
			
		||||
                    className = (prop.DeclaringType.IsNested ? $"{prop.DeclaringType.Namespace}.{prop.DeclaringType.DeclaringType.Name}.{prop.DeclaringType.Name}" : $"{prop.DeclaringType.Namespace}.{prop.DeclaringType.Name}").Trim('.');
 | 
			
		||||
                    node = xmlNav.SelectSingleNode($"/doc/members/member[@name='P:{className}.{prop.Name}']/summary");
 | 
			
		||||
                    if (node == null) continue;
 | 
			
		||||
                    var comment = node.InnerXml.Trim(' ', '\r', '\n', '\t');
 | 
			
		||||
                    if (string.IsNullOrEmpty(comment)) continue;
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,7 @@ namespace FreeSql.Internal.Model
 | 
			
		||||
        public string DbName { get; set; }
 | 
			
		||||
        public string DbOldName { get; set; }
 | 
			
		||||
        public bool DisableSyncStructure { get; set; }
 | 
			
		||||
        public string Comment { get; internal set; }
 | 
			
		||||
 | 
			
		||||
        public ColumnInfo VersionColumn { get; set; }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -69,6 +69,7 @@ namespace FreeSql.Internal
 | 
			
		||||
            var propsLazy = new List<NaviteTuple<PropertyInfo, bool, bool, MethodInfo, MethodInfo>>();
 | 
			
		||||
            var propsNavObjs = new List<PropertyInfo>();
 | 
			
		||||
            var propsComment = CommonUtils.GetProperyCommentBySummary(entity);
 | 
			
		||||
            trytb.Comment = propsComment.TryGetValue("", out var tbcomment) ? tbcomment : "";
 | 
			
		||||
            var columnsList = new List<ColumnInfo>();
 | 
			
		||||
            foreach (var p in trytb.Properties.Values)
 | 
			
		||||
            {
 | 
			
		||||
@@ -370,7 +371,7 @@ namespace FreeSql.Internal
 | 
			
		||||
            foreach (var col in trytb.Primarys)
 | 
			
		||||
            {
 | 
			
		||||
                col.Attribute.IsNullable = false;
 | 
			
		||||
                col.Attribute.DbType = col.Attribute.DbType.Replace("NOT NULL", "");
 | 
			
		||||
                col.Attribute.DbType = col.Attribute.DbType.Replace("NOT NULL", "").Trim();
 | 
			
		||||
            }
 | 
			
		||||
            foreach (var col in trytb.Columns.Values)
 | 
			
		||||
            {
 | 
			
		||||
@@ -795,7 +796,14 @@ namespace FreeSql.Internal
 | 
			
		||||
                        trytb.AddOrUpdateTableRef(pnv.Name, nvref);
 | 
			
		||||
 | 
			
		||||
                        if (tbmid.Primarys.Any() == false)
 | 
			
		||||
                        {
 | 
			
		||||
                            tbmid.Primarys = tbmid.Columns.Values.Where(a => a.Attribute.IsPrimary == true).ToArray();
 | 
			
		||||
                            foreach (var col in tbmid.Primarys)
 | 
			
		||||
                            {
 | 
			
		||||
                                col.Attribute.IsNullable = false;
 | 
			
		||||
                                col.Attribute.DbType = col.Attribute.DbType.Replace("NOT NULL", "").Trim();
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    if (isLazy)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user