Skip to content

Commit

Permalink
Add FindInSet_Handler Only For MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheldon-NULL committed Sep 20, 2024
1 parent e5b69b8 commit 98994f9
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Chloe.MySql/MethodHandlers/FindInSet_Handler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#region
/*----------------------------------------------------------------
Copyright (C) 2024 Sheldon
文件名:ZSiteConfigModel
文件功能描述:
创建标识:Sheldon - 2024/04/11 11:19
修改标识:Sheldon - 2024/04/11 11:19
修改描述:[v1.0.1] 添加“xx”功能: ()
修改标识:LG - 2024/04/11 11:19
修改描述:处理偶然出现的 xxx 问题
----------------------------------------------------------------*/
#endregion

using Chloe.DbExpressions;
using Chloe.RDBMS;
using Chloe.RDBMS.MethodHandlers;

namespace Chloe.MySql.MethodHandlers
{
class FindInSet_Handler: FindInSet_HandlerBase
{
public override void Process(DbMethodCallExpression exp, SqlGeneratorBase generator)
{
generator.SqlBuilder.Append(" FIND_IN_SET(");
exp.Arguments[1].Accept(generator);
generator.SqlBuilder.Append(",");
exp.Arguments[0].Accept(generator);
generator.SqlBuilder.Append(")");
}
}
}
33 changes: 33 additions & 0 deletions src/Chloe/Extensions/StringExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#region
/*----------------------------------------------------------------
Copyright (C) 2024 Sheldon
文件名:ZSiteConfigModel
文件功能描述:
创建标识:Sheldon - 2024/04/11 11:19
修改标识:Sheldon - 2024/04/11 11:19
修改描述:[v1.0.1] 添加“xx”功能: ()
修改标识:LG - 2024/04/11 11:19
修改描述:处理偶然出现的 xxx 问题
----------------------------------------------------------------*/
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chloe.Extensions
{
public static class StringExtension
{
public static bool FindInSet(this string str, string value)
{
return str.Split(',').Contains(value);
}
}
}
16 changes: 16 additions & 0 deletions src/Chloe/RDBMS/MethodHandlers/FindInSet_HandlerBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Chloe.Annotations;
using Chloe.DbExpressions;
using System.Collections;
using System.Data;
using System.Reflection;

namespace Chloe.RDBMS.MethodHandlers
{
public class FindInSet_HandlerBase : MethodHandlerBase
{

public override bool CanProcess(DbMethodCallExpression exp) => exp.Method.IsDefined(typeof(DbFunctionAttribute));


}
}

0 comments on commit 98994f9

Please sign in to comment.