当前位置: 首页>>代码示例>>C#>>正文


C# IEntityPersister.SetDbParamter方法代码示例

本文整理汇总了C#中IEntityPersister.SetDbParamter方法的典型用法代码示例。如果您正苦于以下问题:C# IEntityPersister.SetDbParamter方法的具体用法?C# IEntityPersister.SetDbParamter怎么用?C# IEntityPersister.SetDbParamter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEntityPersister的用法示例。


在下文中一共展示了IEntityPersister.SetDbParamter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetConditaion

        private static string GetConditaion(ISessionImplementor session, IEntityPersister entityPersister, IEntity obj, out List<DbParameter> parameters)
        {
            var rConditaion = obj.Conditaion;
            var classMetadata = entityPersister.ClassMetadata;
            parameters = new List<DbParameter>();
            foreach (ColumnInfo columnInfo in classMetadata.ColumnInfos)
            {
                var value = columnInfo.PropertyInfo.FastGetValue(obj);
                if (IsNull(value)) continue;
                if (IsNullValue(value) && columnInfo.IsNullable) continue;

                var index = Contains(obj.Conditaion, columnInfo.PropertyName);
                if (index == 0)
                {
                    rConditaion = rConditaion.Replace(string.Format(LikeString[0], columnInfo.PropertyName), entityPersister.Driver.FormatNameForSql(columnInfo.Name));
                    entityPersister.SetDbParamter(session, parameters, columnInfo.Name, value);
                    //entityPersister.SetDbParamter(session, parameters, classMetadata.PrimaryKey, value);
                }
                else if (index > 0)
                {
                    rConditaion = rConditaion.Replace(string.Format(LikeString[index], columnInfo.PropertyName), string.Format(LikeValueString[index - 1], Escape(value.ToString(), "")));
                }
            }
            return rConditaion;
        }
开发者ID:eicrosoft,项目名称:VipSoft,代码行数:25,代码来源:Map.cs

示例2: CreateUpdateSql

        public static CmdParameter CreateUpdateSql(ISessionImplementor session, IEntityPersister entityPersister, IEntity obj)
        {
            var classMetadata = entityPersister.ClassMetadata;
            var rConditaion = obj.Conditaion;
            var columns = new StringBuilder();

            List<DbParameter> parameters = new List<DbParameter>();
            foreach (ColumnInfo columnInfo in classMetadata.ColumnInfos)
            {
                var value = columnInfo.PropertyInfo.FastGetValue(obj);
                if (IsNull(value)) continue;
                if (columnInfo.IsPrimaryKey && string.IsNullOrEmpty(obj.Conditaion))
                {
                    rConditaion = string.Format("{0}={1}", columnInfo.Name, entityPersister.Driver.FormatNameForSql(columnInfo.Name));
                    entityPersister.SetDbParamter(session, parameters, columnInfo.Name, value);
                }
                else
                {
                    var index = Contains(obj.Conditaion, columnInfo.Name);
                    if (index == 0)
                    {
                        rConditaion = rConditaion.Replace(string.Format(LikeString[0], columnInfo.Name), entityPersister.Driver.FormatNameForSql(columnInfo.Name));
                        entityPersister.SetDbParamter(session, parameters, classMetadata.PKColumnName, value);
                    }
                    else if (index > 0)
                    {
                        rConditaion = rConditaion.Replace(string.Format(LikeString[index], columnInfo.Name), string.Format(LikeValueString[index - 1], Escape(value.ToString(), "")));
                    }
                    else if (index == -1)
                    {
                        columns.AppendFormat("{0}={1},", columnInfo.Name, entityPersister.Driver.FormatNameForSql(columnInfo.Name));

                        if (columnInfo.IsNullable && IsNullValue(value))
                        {
                            entityPersister.SetDbParamter(session, parameters, columnInfo.Name, DBNull.Value);
                        }
                        else
                        {
                            entityPersister.SetDbParamter(session, parameters, columnInfo.Name, value);
                        }
                    }

                }

            }
            var where = GetWhereCaluse(rConditaion);
            var result = new CmdParameter();
            if (where.Length > 0 && columns.Length > 0)
            {
                result.Parameters = parameters.ToArray();
                result.CommandText = string.Format("UPDATE {0} SET {1} WHERE {2}{3}", classMetadata.TableName, columns.Remove(columns.Length - 1, 1), where, entityPersister.Driver.MultipleQueriesSeparator);
            }

            return result;
        }
开发者ID:eicrosoft,项目名称:VipSoft,代码行数:55,代码来源:Map.cs

示例3: CreateSelectSql

 public static CmdParameter CreateSelectSql(ISessionImplementor session, IEntityPersister entityPersister, object pKey)
 {
     var result = new CmdParameter();
     if (pKey != null)
     {
         var classMetadata = entityPersister.ClassMetadata;
         var driver = entityPersister.Driver;
         result.CommandText = string.Format("SELECT * FROM {0} WHERE {1}={2}", classMetadata.TableName, classMetadata.PrimaryKey, driver.FormatNameForSql(classMetadata.PrimaryKey));
         var parameters = new List<DbParameter>();
         entityPersister.SetDbParamter(session, parameters, classMetadata.PKColumnName, pKey);
         result.Parameters = parameters.ToArray();
     }
     return result;
 }
开发者ID:eicrosoft,项目名称:VipSoft,代码行数:14,代码来源:Map.cs

示例4: CreateInsertSql

        public static CmdParameter CreateInsertSql(ISessionImplementor session, IEntityPersister entityPersister, IEntity obj)
        {
            var result = new CmdParameter();

            var classMetadata = entityPersister.ClassMetadata;
            var driver = entityPersister.Driver;

            var sql = new StringBuilder("INSERT INTO");
            sql.AppendFormat(" {0} (", classMetadata.TableName);
            var values = new StringBuilder();
            var tParameters = new List<DbParameter>();
            var columnInfos = classMetadata.ColumnInfos.FindAll(t => t.IsColumn);

            foreach (var columnInfo in columnInfos)
            {
                var v = columnInfo.PropertyInfo.FastGetValue(obj);
                if (IsNull(v)) continue;
                if (columnInfo.IsNullable && IsNullValue(v)) continue;
                sql.AppendFormat("{0},", columnInfo.Name);
                values.AppendFormat("{0},", driver.FormatNameForSql(columnInfo.Name));
                entityPersister.SetDbParamter(session, tParameters, columnInfo.Name, v);
            }
            if (values.Length > 0)
            {
                sql.Replace(',', ')', sql.Length - 1, 1);
                sql.AppendFormat(" VALUES ({0}){1}", values.Remove(values.Length - 1, 1), driver.MultipleQueriesSeparator);

                result.CommandText = sql.ToString();
                result.Parameters = tParameters.ToArray();
            }

            return result;
        }
开发者ID:eicrosoft,项目名称:VipSoft,代码行数:33,代码来源:Map.cs

示例5: CreateDeleteWithValidateSql

        public static CmdParameter CreateDeleteWithValidateSql(ISessionImplementor session, IEntityPersister entityPersister, params object[] pKeys)
        {
            var result = new CmdParameter();
            var classMetadata = entityPersister.ClassMetadata;
            var driver = entityPersister.Driver;

            if (pKeys.Length == 1)
            {
                result.CommandText = string.Format("Delete FROM {0} WHERE {1} IN ( SELECT {1} FROM (SELECT M.{1} FROM {0} AS M  LEFT JOIN {2} AS S ON M.ID=S.{3} WHERE M.{1}={4} AND S.{3} IS NULL )AS MS ){5}", classMetadata.TableName, classMetadata.PrimaryKey, classMetadata.AssociateTable, classMetadata.ForeignKey, driver.FormatNameForSql(classMetadata.PrimaryKey), driver.MultipleQueriesSeparator);
                var parameters = new List<DbParameter>();
                entityPersister.SetDbParamter(session, parameters, classMetadata.PrimaryKey, pKeys[0]);
                result.Parameters = parameters.ToArray();
            }
            else if (pKeys.Length > 1)
            {
                result.CommandText = string.Format("Delete FROM {0} WHERE {1} IN ( SELECT {1} FROM (SELECT M.{1} FROM {0} AS M  LEFT JOIN {2} AS S ON M.ID=S.{3} WHERE M.{1} {4} AND S.{3} IS NULL )AS MS ){5}", classMetadata.TableName, classMetadata.PrimaryKey, classMetadata.AssociateTable, classMetadata.ForeignKey, GetInExpression(pKeys), driver.MultipleQueriesSeparator);
            }

            return result;
        }
开发者ID:eicrosoft,项目名称:VipSoft,代码行数:20,代码来源:Map.cs

示例6: CreateDeleteSql

        public static CmdParameter CreateDeleteSql(ISessionImplementor session, IEntityPersister entityPersister, params object[] pKeys)
        {
            var result = new CmdParameter();
            var classMetadata = entityPersister.ClassMetadata;
            var driver = entityPersister.Driver;
            if (pKeys.Length == 1)
            {
                result.CommandText = string.Format("DELETE FROM {0} WHERE {1}={2}{3}", classMetadata.TableName, classMetadata.PKColumnName, driver.FormatNameForSql(classMetadata.PKColumnName), driver.MultipleQueriesSeparator);
                var parameters = new List<DbParameter>();
                entityPersister.SetDbParamter(session, parameters, classMetadata.PKColumnName, pKeys[0]);
                result.Parameters = parameters.ToArray();
            }
            else if (pKeys.Length > 1)
            {
                result.CommandText = string.Format("DELETE FROM {0} WHERE {1} {2}{3}", classMetadata.TableName, classMetadata.PKColumnName, GetInExpression(pKeys), driver.MultipleQueriesSeparator);
            }

            return result;
        }
开发者ID:eicrosoft,项目名称:VipSoft,代码行数:19,代码来源:Map.cs


注:本文中的IEntityPersister.SetDbParamter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。