Skip to content

Commit

Permalink
fix Nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Jul 20, 2024
1 parent 876dfb5 commit 4e7a8b7
Show file tree
Hide file tree
Showing 26 changed files with 58 additions and 54 deletions.
4 changes: 2 additions & 2 deletions XCode/Code/EntityBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,7 @@ protected virtual Boolean BuildExtendFind(IDataColumn[] columns, Int32 index)
WriteLine("if ({0} < 0) return null;", dc.CamelName());
else if (dc.DataType == typeof(String))
{
if (nullable && !dc.Nullable)
if (nullable && dc.Nullable)
WriteLine("if ({0} == null) return null;", dc.CamelName());
else
WriteLine("if ({0}.IsNullOrEmpty()) return null;", dc.CamelName());
Expand Down Expand Up @@ -1753,7 +1753,7 @@ protected virtual Boolean BuildExtendFindAll(IDataColumn[] columns, Int32 index)
WriteLine("if ({0} < 0) return [];", dc.CamelName(), ClassName);
else if (dc.DataType == typeof(String))
{
if (Option.Nullable && !dc.Nullable)
if (Option.Nullable && dc.Nullable)
WriteLine("if ({0} == null) return [];", dc.CamelName());
else
WriteLine("if ({0}.IsNullOrEmpty()) return [];", dc.CamelName(), ClassName);
Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Code/Entity/地区.Biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public override Boolean Valid(DataMethod method)
/// <param name="key">关键字</param>
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
/// <returns>实体列表</returns>
public static IList<Area> Search(String name, Int32 parentId, String pinYin, String jianPin, String geoHash, DateTime start, DateTime end, String key, PageParameter page)
public static IList<Area> Search(String? name, Int32 parentId, String? pinYin, String? jianPin, String? geoHash, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();

Expand Down
8 changes: 4 additions & 4 deletions XUnitTest.XCode/Code/Entity/地区.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public static IList<Area> FindAllByParentID(Int32 parentId)
/// <summary>根据名称查找</summary>
/// <param name="name">名称</param>
/// <returns>实体列表</returns>
public static IList<Area> FindAllByName(String name)
public static IList<Area> FindAllByName(String? name)
{
if (name == null) return [];

Expand All @@ -306,7 +306,7 @@ public static IList<Area> FindAllByName(String name)
/// <summary>根据拼音查找</summary>
/// <param name="pinYin">拼音</param>
/// <returns>实体列表</returns>
public static IList<Area> FindAllByPinYin(String pinYin)
public static IList<Area> FindAllByPinYin(String? pinYin)
{
if (pinYin == null) return [];

Expand All @@ -319,7 +319,7 @@ public static IList<Area> FindAllByPinYin(String pinYin)
/// <summary>根据简拼查找</summary>
/// <param name="jianPin">简拼</param>
/// <returns>实体列表</returns>
public static IList<Area> FindAllByJianPin(String jianPin)
public static IList<Area> FindAllByJianPin(String? jianPin)
{
if (jianPin == null) return [];

Expand All @@ -332,7 +332,7 @@ public static IList<Area> FindAllByJianPin(String jianPin)
/// <summary>根据地址编码查找</summary>
/// <param name="geoHash">地址编码</param>
/// <returns>实体列表</returns>
public static IList<Area> FindAllByGeoHash(String geoHash)
public static IList<Area> FindAllByGeoHash(String? geoHash)
{
if (geoHash == null) return [];

Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Code/Entity/字典参数.Biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public override Boolean Valid(DataMethod method)
/// <param name="key">关键字</param>
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
/// <returns>实体列表</returns>
public static IList<Parameter> Search(Int32 userId, String category, String name, DateTime start, DateTime end, String key, PageParameter page)
public static IList<Parameter> Search(Int32 userId, String? category, String? name, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();

Expand Down
6 changes: 3 additions & 3 deletions XUnitTest.XCode/Code/Entity/字典参数.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public override Object? this[String name]
/// <param name="category">类别</param>
/// <param name="name">名称</param>
/// <returns>实体对象</returns>
public static Parameter? FindByUserIDAndCategoryAndName(Int32 userId, String category, String name)
public static Parameter? FindByUserIDAndCategoryAndName(Int32 userId, String? category, String? name)
{
if (userId < 0) return null;
if (category == null) return null;
Expand Down Expand Up @@ -383,7 +383,7 @@ public static IList<Parameter> FindAllByUserID(Int32 userId)
/// <param name="userId">用户</param>
/// <param name="category">类别</param>
/// <returns>实体列表</returns>
public static IList<Parameter> FindAllByUserIDAndCategory(Int32 userId, String category)
public static IList<Parameter> FindAllByUserIDAndCategory(Int32 userId, String? category)
{
if (userId < 0) return [];
if (category == null) return [];
Expand All @@ -398,7 +398,7 @@ public static IList<Parameter> FindAllByUserIDAndCategory(Int32 userId, String c
/// <param name="category">类别</param>
/// <param name="name">名称</param>
/// <returns>实体列表</returns>
public static IList<Parameter> FindAllByCategoryAndName(String category, String name)
public static IList<Parameter> FindAllByCategoryAndName(String? category, String? name)
{
if (category == null) return [];
if (name == null) return [];
Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Code/Entity/成员日志.Biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public override Boolean Valid(DataMethod method)
/// <param name="key">关键字</param>
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
/// <returns>实体列表</returns>
public static IList<MemberLog> Search(String category, String action, Int32 linkId, Int32 createUserId, DateTime start, DateTime end, String key, PageParameter page)
public static IList<MemberLog> Search(String? category, String? action, Int32 linkId, Int32 createUserId, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();

Expand Down
4 changes: 2 additions & 2 deletions XUnitTest.XCode/Code/Entity/成员日志.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public override Object? this[String name]
/// <param name="action">操作</param>
/// <param name="category">类别</param>
/// <returns>实体列表</returns>
public static IList<MemberLog> FindAllByActionAndCategory(String action, String category)
public static IList<MemberLog> FindAllByActionAndCategory(String? action, String? category)
{
if (action == null) return [];
if (category == null) return [];
Expand All @@ -310,7 +310,7 @@ public static IList<MemberLog> FindAllByActionAndCategory(String action, String
/// <param name="category">类别</param>
/// <param name="linkId">链接</param>
/// <returns>实体列表</returns>
public static IList<MemberLog> FindAllByCategoryAndLinkID(String category, Int32 linkId)
public static IList<MemberLog> FindAllByCategoryAndLinkID(String? category, Int32 linkId)
{
if (category == null) return [];
if (linkId < 0) return [];
Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Code/Entity/日志.Biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public override Boolean Valid(DataMethod method)
/// <param name="key">关键字</param>
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
/// <returns>实体列表</returns>
public static IList<Log> Search(String category, String action, Int32 linkId, Int32 createUserId, DateTime start, DateTime end, String key, PageParameter page)
public static IList<Log> Search(String? category, String? action, Int32 linkId, Int32 createUserId, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();

Expand Down
4 changes: 2 additions & 2 deletions XUnitTest.XCode/Code/Entity/日志.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public override Object? this[String name]
/// <param name="action">操作</param>
/// <param name="category">类别</param>
/// <returns>实体列表</returns>
public static IList<Log> FindAllByActionAndCategory(String action, String category)
public static IList<Log> FindAllByActionAndCategory(String? action, String? category)
{
if (action == null) return [];
if (category == null) return [];
Expand All @@ -301,7 +301,7 @@ public static IList<Log> FindAllByActionAndCategory(String action, String catego
/// <param name="category">类别</param>
/// <param name="linkId">链接</param>
/// <returns>实体列表</returns>
public static IList<Log> FindAllByCategoryAndLinkID(String category, Int32 linkId)
public static IList<Log> FindAllByCategoryAndLinkID(String? category, Int32 linkId)
{
if (category == null) return [];
if (linkId < 0) return [];
Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Code/Entity/用户.Biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public override Boolean Valid(DataMethod method)
/// <param name="key">关键字</param>
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
/// <returns>实体列表</returns>
public static IList<User> Search(String name, String mail, String mobile, String code, Int32 roleId, DateTime start, DateTime end, String key, PageParameter page)
public static IList<User> Search(String name, String? mail, String? mobile, String? code, Int32 roleId, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();

Expand Down
8 changes: 4 additions & 4 deletions XUnitTest.XCode/Code/Entity/用户.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static User? FindByName(String name)
{
if (name == null) return null;
if (name.IsNullOrEmpty()) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
Expand All @@ -505,7 +505,7 @@ public override Object? this[String name]
/// <summary>根据邮件查找</summary>
/// <param name="mail">邮件</param>
/// <returns>实体列表</returns>
public static IList<User> FindAllByMail(String mail)
public static IList<User> FindAllByMail(String? mail)
{
if (mail == null) return [];

Expand All @@ -518,7 +518,7 @@ public static IList<User> FindAllByMail(String mail)
/// <summary>根据手机查找</summary>
/// <param name="mobile">手机</param>
/// <returns>实体列表</returns>
public static IList<User> FindAllByMobile(String mobile)
public static IList<User> FindAllByMobile(String? mobile)
{
if (mobile == null) return [];

Expand All @@ -531,7 +531,7 @@ public static IList<User> FindAllByMobile(String mobile)
/// <summary>根据代码查找</summary>
/// <param name="code">代码</param>
/// <returns>实体列表</returns>
public static IList<User> FindAllByCode(String code)
public static IList<User> FindAllByCode(String? code)
{
if (code == null) return [];

Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Code/Entity/用户日志.Biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public override Boolean Valid(DataMethod method)
/// <param name="key">关键字</param>
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
/// <returns>实体列表</returns>
public static IList<UserLog> Search(String category, String action, Int32 linkId, Int32 createUserId, DateTime start, DateTime end, String key, PageParameter page)
public static IList<UserLog> Search(String? category, String? action, Int32 linkId, Int32 createUserId, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();

Expand Down
4 changes: 2 additions & 2 deletions XUnitTest.XCode/Code/Entity/用户日志.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public override Object? this[String name]
/// <param name="action">操作</param>
/// <param name="category">类别</param>
/// <returns>实体列表</returns>
public static IList<UserLog> FindAllByActionAndCategory(String action, String category)
public static IList<UserLog> FindAllByActionAndCategory(String? action, String? category)
{
if (action == null) return [];
if (category == null) return [];
Expand All @@ -312,7 +312,7 @@ public static IList<UserLog> FindAllByActionAndCategory(String action, String ca
/// <param name="category">类别</param>
/// <param name="linkId">链接</param>
/// <returns>实体列表</returns>
public static IList<UserLog> FindAllByCategoryAndLinkID(String category, Int32 linkId)
public static IList<UserLog> FindAllByCategoryAndLinkID(String? category, Int32 linkId)
{
if (category == null) return [];
if (linkId < 0) return [];
Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Code/Entity/租户.Biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public override Boolean Valid(DataMethod method)
/// <param name="key">关键字</param>
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
/// <returns>实体列表</returns>
public static IList<Tenant> Search(String code, DateTime start, DateTime end, String key, PageParameter page)
public static IList<Tenant> Search(String? code, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();

Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Code/Entity/租户.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public override Object? this[String name]
/// <summary>根据编码查找</summary>
/// <param name="code">编码</param>
/// <returns>实体对象</returns>
public static Tenant? FindByCode(String code)
public static Tenant? FindByCode(String? code)
{
if (code == null) return null;

Expand Down
4 changes: 2 additions & 2 deletions XUnitTest.XCode/Code/Entity/菜单.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public override Object? this[String name]
/// <returns>实体列表</returns>
public static IList<Menu> FindAllByName(String name)
{
if (name == null) return [];
if (name.IsNullOrEmpty()) return [];

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Name.EqualIgnoreCase(name));
Expand All @@ -404,7 +404,7 @@ public static IList<Menu> FindAllByName(String name)
public static Menu? FindByParentIDAndName(Int32 parentId, String name)
{
if (parentId < 0) return null;
if (name == null) return null;
if (name.IsNullOrEmpty()) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ParentID == parentId && e.Name.EqualIgnoreCase(name));
Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Code/Entity/角色.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static Role? FindByName(String name)
{
if (name == null) return null;
if (name.IsNullOrEmpty()) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Code/Entity/部门.Biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public override Boolean Valid(DataMethod method)
/// <param name="key">关键字</param>
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
/// <returns>实体列表</returns>
public static IList<Department> Search(Int32 tenantId, String code, String name, Int32 parentId, DateTime start, DateTime end, String key, PageParameter page)
public static IList<Department> Search(Int32 tenantId, String? code, String name, Int32 parentId, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();

Expand Down
6 changes: 3 additions & 3 deletions XUnitTest.XCode/Code/Entity/部门.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public override Object? this[String name]
/// <returns>实体列表</returns>
public static IList<Department> FindAllByName(String name)
{
if (name == null) return [];
if (name.IsNullOrEmpty()) return [];

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Name.EqualIgnoreCase(name));
Expand All @@ -412,7 +412,7 @@ public static IList<Department> FindAllByName(String name)
public static IList<Department> FindAllByParentIDAndName(Int32 parentId, String name)
{
if (parentId < 0) return [];
if (name == null) return [];
if (name.IsNullOrEmpty()) return [];

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.ParentID == parentId && e.Name.EqualIgnoreCase(name));
Expand All @@ -423,7 +423,7 @@ public static IList<Department> FindAllByParentIDAndName(Int32 parentId, String
/// <summary>根据代码查找</summary>
/// <param name="code">代码</param>
/// <returns>实体列表</returns>
public static IList<Department> FindAllByCode(String code)
public static IList<Department> FindAllByCode(String? code)
{
if (code == null) return [];

Expand Down
6 changes: 3 additions & 3 deletions XUnitTest.XCode/Code/entity_log_normal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ public override Object? this[String name]
/// <param name="action">操作</param>
/// <param name="category">类别</param>
/// <returns>实体列表</returns>
public static IList<Log> FindAllByActionAndCategory(String action, String category)
public static IList<Log> FindAllByActionAndCategory(String action, String? category)
{
if (action == null) return [];
if (action.IsNullOrEmpty()) return [];
if (category == null) return [];

return FindAll(_.Action == action & _.Category == category);
Expand All @@ -269,7 +269,7 @@ public static IList<Log> FindAllByActionAndCategory(String action, String catego
/// <param name="category">类别</param>
/// <param name="linkId">链接</param>
/// <returns>实体列表</returns>
public static IList<Log> FindAllByCategoryAndLinkID(String category, Int64 linkId)
public static IList<Log> FindAllByCategoryAndLinkID(String? category, Int64 linkId)
{
if (category == null) return [];
if (linkId < 0) return [];
Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Code/entity_log_normal_biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public override Boolean Valid(DataMethod method)
/// <param name="key">关键字</param>
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
/// <returns>实体列表</returns>
public static IList<Log> Search(String category, String action, Int64 linkId, Int32 createUserId, DateTime start, DateTime end, String key, PageParameter page)
public static IList<Log> Search(String? category, String action, Int64 linkId, Int32 createUserId, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();

Expand Down
8 changes: 4 additions & 4 deletions XUnitTest.XCode/Code/entity_user_normal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static User? FindByName(String name)
{
if (name == null) return null;
if (name.IsNullOrEmpty()) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
Expand All @@ -478,7 +478,7 @@ public override Object? this[String name]
/// <summary>根据邮件查找</summary>
/// <param name="mail">邮件</param>
/// <returns>实体列表</returns>
public static IList<User> FindAllByMail(String mail)
public static IList<User> FindAllByMail(String? mail)
{
if (mail == null) return [];

Expand All @@ -491,7 +491,7 @@ public static IList<User> FindAllByMail(String mail)
/// <summary>根据手机查找</summary>
/// <param name="mobile">手机</param>
/// <returns>实体列表</returns>
public static IList<User> FindAllByMobile(String mobile)
public static IList<User> FindAllByMobile(String? mobile)
{
if (mobile == null) return [];

Expand All @@ -504,7 +504,7 @@ public static IList<User> FindAllByMobile(String mobile)
/// <summary>根据代码查找</summary>
/// <param name="code">代码</param>
/// <returns>实体列表</returns>
public static IList<User> FindAllByCode(String code)
public static IList<User> FindAllByCode(String? code)
{
if (code == null) return [];

Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Code/entity_user_normal_biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public override Boolean Valid(DataMethod method)
/// <param name="key">关键字</param>
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
/// <returns>实体列表</returns>
public static IList<User> Search(String name, String mail, String mobile, String code, Int32 roleId, Int32 departmentId, DateTime start, DateTime end, String key, PageParameter page)
public static IList<User> Search(String name, String? mail, String? mobile, String? code, Int32 roleId, Int32 departmentId, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();

Expand Down
Loading

0 comments on commit 4e7a8b7

Please sign in to comment.