工作日记

工作日记

c#

  • 字符串枚举

c#枚举一般只能用int,通过以下代码可以实现字符串枚举

//定义枚举
	 enum WARNING
   	 {
      		  [EnumDescription("输入范围为空!请输入")]
      		  NULLWARNING_1
    	 }

	/// <summary>
        ///自定义属性
        /// </summary>
 
     [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
      public sealed class EnumDescriptionAttribute : Attribute
        {
            private string description;
            public string Description { get { return description; } }
            public EnumDescriptionAttribute(string description)
                : base()
            {
                this.description = description;
            }
        }
	 /// <summary>
        /// 获取枚举字符串
        /// </summary>
	 public static class EnumHelper
        {
            public static string GetDescription(Enum value)
            {
                if (value == null)
                {
                    throw new ArgumentException("value");
                }
                string description = value.ToString();
                var fieldInfo = value.GetType().GetField(description);
                var attributes =
                    (EnumDescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(EnumDescriptionAttribute), false);
                if (attributes != null && attributes.Length > 0)
                {
                    description = attributes[0].Description;
                }
                return description;
            }
        }

详细解释

sql

  • 类型转换

字符串转INTEGER

`cast(start_no as INTEGER)`
  • Oracle分层查询以及PGsql同样实现的方法

Oracle实现:

select * from sr_menu 
start with id = 1 
connect by prior id = parent;

PGsql实现:

WITH RECURSIVE a AS (
SELECT id, parent, title
  FROM sr_menu
  WHERE id = 1
UNION ALL
  SELECT d.id, d.parent, d.title
  FROM sr_menu d
  JOIN a ON a.id = d.parent )
SELECT id, parent, title FROM a;

详细解释

mybatis

  • <if 标签使用

<if 标签使用时判断等于单个字符串时,不能用双引号来判断等于字符串,会判定char与string不匹配
错误示范 :

<if test="isStandard!='N'">
          and  is_standard= #{isStandard,jdbcType=VARCHAR}
</if>

正确代码:

<if test='isStandard!="N"'>
          and  is_standard= #{isStandard,jdbcType=VARCHAR}
</if>

Java

  • stream流和lambda表达式

stream_1
stream_2
lambda

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值