示例#1
0
 protected virtual string GetInsertParameterNameList <TTableObject>(WhereClauseBuilder <TTableObject> whereClauseBuilder)
     where TTableObject : class, new()
 => string.Format(", ", typeof(TTableObject)
                  .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.SetProperty)
                  .Where(p => !p.IsDefined(typeof(KeyAttribute)) || !p.GetCustomAttribute <KeyAttribute>().AutoGenerated)
                  .Select(p => $"{whereClauseBuilder.ParameterChar}{p.Name.ToLower()}")
                  );
示例#2
0
 protected virtual string GetUpdateCriteriaParameterNameList <TTableObject>(WhereClauseBuilder <TTableObject> whereClauseBuilder, UpdateCriteria <TTableObject> updateCriteria)
     where TTableObject : class, new()
 => string.Join(", ", updateCriteria.Select(uc => $"{uc.Key}={whereClauseBuilder.ParameterChar}u_{uc.Key}"));
示例#3
0
        protected virtual IEnumerable <DbParameter> GetInsertDbParameterList <TTableObject>(TTableObject obj, WhereClauseBuilder <TTableObject> whereClauseBuilder)
            where TTableObject : class, new()
        {
            var parameters = new List <DbParameter>();

            typeof(TTableObject)
            .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.SetProperty)
            .Where(p => !p.IsDefined(typeof(KeyAttribute)) || !p.GetCustomAttribute <KeyAttribute>().AutoGenerated)
            .ToList()
            .ForEach(p =>
            {
                var parameter           = this.CreateParameter();
                parameter.ParameterName = $"{whereClauseBuilder.ParameterChar}{p.Name.ToLower()}";
                parameter.Value         = p.GetValue(obj);
                parameters.Add(parameter);
            });
            return(parameters);
        }