LambdaToSql/Attribute/PrimaryKey.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;


namespace LambdaToSql.Attribute
{
    /// <summary>
    /// 是否为主键
    /// </summary>
    public class LambdaToSqlAttribute : System.Attribute
    {
        /// <summary>
        /// 是否主键列
        /// </summary>
        public bool IsPrimaryKey { get; set; }

        /// <summary>
        /// 是否标识列
        /// </summary>
        public bool IsIdentity { get; set; }


        //public static LambdaToSqlAttribute GetAttribute(PropertyInfo pi)
        //{
        //    var obj = System.Attribute.GetCustomAttribute(pi, typeof(LambdaToSqlAttribute)) as LambdaToSqlAttribute;
        //    if (obj == null)
        //    {
        //        obj = new LambdaToSqlAttribute() { IsIdentity = false, IsPrimaryKey = false };
        //    }
        //    return obj;
        //}

        ///// <summary>
        ///// 获取主键列
        ///// </summary>
        ///// <typeparam name="T"></typeparam> 
        ///// <returns></returns>
        //public static List<string> GetPrimaryKey<T>() where T : class, new()
        //{
        //    var properties = (new T()).GetType().GetProperties();
        //    var list = GetPrimaryKey(properties);
        //    return list;
        //}

        ///// <summary>
        ///// 获取主键列
        ///// </summary>
        ///// <param name="properties"></param>
        ///// <returns></returns>
        //public static List<string> GetPrimaryKey(PropertyInfo[] properties)
        //{
        //    var list = new List<string>();
        //    foreach (PropertyInfo pi in properties)
        //    {
        //        var obj = (LambdaToSqlAttribute)System.Attribute.GetCustomAttribute(pi, typeof(LambdaToSqlAttribute));
        //        if (obj != null)
        //        {
后面还有 44 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。