Beispiel #1
0
 static object CacheData_GetData(string tableName)
 {
     switch (tableName)
     {
     case "SysCodeRule":
         var context = CoreDBContext.GetContext();
         return(context.Set <CodeRuleEntity>().Where(x => x.IsValid == true).ToList());
     }
     return(null);
 }
        public string GetCode(ICodeRuleEntity codeRule, object entity, bool isTemp)
        {
            var    context                 = CoreDBContext.GetContext();
            string generateRule            = AnalyseGenerateRule(codeRule.GenerateRule, entity);
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter()
            {
                ParameterName = "@TableName", Value = codeRule.TableName, SqlDbType = System.Data.SqlDbType.NVarChar, Size = 50
            });
            parameters.Add(new SqlParameter()
            {
                ParameterName = "@FieldName", Value = codeRule.FieldName, SqlDbType = System.Data.SqlDbType.NVarChar, Size = 50
            });
            parameters.Add(new SqlParameter()
            {
                ParameterName = "@GenerateRule", Value = generateRule, SqlDbType = System.Data.SqlDbType.NVarChar, Size = 100
            });
            parameters.Add(new SqlParameter()
            {
                ParameterName = "@DateRule", Value = codeRule.DateRule ?? "", SqlDbType = System.Data.SqlDbType.NVarChar, Size = 50
            });
            parameters.Add(new SqlParameter()
            {
                ParameterName = "@AutoIncreaceRule", Value = codeRule.AutoIncreaceRule ?? "", SqlDbType = System.Data.SqlDbType.NVarChar, Size = 10
            });
            parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsTemp", Value = isTemp, SqlDbType = System.Data.SqlDbType.Bit
            });
            parameters.Add(new SqlParameter()
            {
                ParameterName = "@OutValue", SqlDbType = System.Data.SqlDbType.NVarChar, Size = 100, Direction = System.Data.ParameterDirection.Output
            });
            context.Database.ExecuteSqlCommand("Exec dbo.SP_GetCodeByCodeRule @TableName,@FieldName,@GenerateRule,@DateRule,@AutoIncreaceRule,@IsTemp,@OutValue OUTPUT", parameters.ToArray());
            return(Convert.ToString(parameters[6].Value));
        }