コード例 #1
0
 public override bool Update(TerminationChoiceRow value)
 {
     if (value != null)
     {
         throw new NotSupportedException();
     }
     return(false);
 }
コード例 #2
0
        public override void Insert(TerminationChoiceRow value)
        {
            //			string _id_param = base.Database.CreateSqlParameterName(TerminationChoiceRow.termination_choice_id_PropName);
            //			string _priority_param = base.Database.CreateSqlParameterName(TerminationChoiceRow.priority_PropName);
            string _sqlStr =
                //				"DECLARE " + _id_param + " int " +
                //				"DECLARE " + _priority_param + " tinyint " +

                "SET " + Database.CreateSqlParameterName(TerminationChoiceRow.termination_choice_id_PropName) +
                " = COALESCE((SELECT MAX(" + TerminationChoiceRow.termination_choice_id_DbName + ") FROM [dbo].[TerminationChoice]) + 1, 1) " +

                "SET " + Database.CreateSqlParameterName(TerminationChoiceRow.priority_PropName) +
                " = COALESCE((SELECT MAX(" + TerminationChoiceRow.priority_DbName + ") FROM [dbo].[TerminationChoice] " +
                "WHERE [" + TerminationChoiceRow.routing_plan_id_DbName + "]=" +
                base.Database.CreateSqlParameterName(TerminationChoiceRow.routing_plan_id_PropName) +
                " AND [" + TerminationChoiceRow.route_id_DbName + "]=" +
                base.Database.CreateSqlParameterName(TerminationChoiceRow.route_id_PropName) +
                ") + 1, 1) " +

                "INSERT INTO [dbo].[TerminationChoice] (" +
                "[" + TerminationChoiceRow.termination_choice_id_DbName + "], " +
                "[" + TerminationChoiceRow.routing_plan_id_DbName + "], " +
                "[" + TerminationChoiceRow.route_id_DbName + "], " +
                "[" + TerminationChoiceRow.priority_DbName + "], " +
                "[" + TerminationChoiceRow.carrier_route_id_DbName + "], " +
                "[" + TerminationChoiceRow.version_DbName + "] " +
                ") VALUES (" +
                Database.CreateSqlParameterName(TerminationChoiceRow.termination_choice_id_PropName) + ", " +
                Database.CreateSqlParameterName(TerminationChoiceRow.routing_plan_id_PropName) + ", " +
                Database.CreateSqlParameterName(TerminationChoiceRow.route_id_PropName) + ", " +
                Database.CreateSqlParameterName(TerminationChoiceRow.priority_PropName) + ", " +
                Database.CreateSqlParameterName(TerminationChoiceRow.carrier_route_id_PropName) + ", " +
                Database.CreateSqlParameterName(TerminationChoiceRow.version_PropName) + ") ";

            IDbCommand _cmd = Database.CreateCommand(_sqlStr);
            //AddParameter(cmd, "Termination_choice_id", value.Termination_choice_id);
            IDbDataParameter _id_param = _cmd.CreateParameter();

            _id_param.ParameterName = Database.CreateSqlParameterName(TerminationChoiceRow.termination_choice_id_PropName);
            _id_param.DbType        = DbType.Int32;
            _id_param.Direction     = ParameterDirection.Output;
            _cmd.Parameters.Add(_id_param);

            //AddParameter(cmd, "Priority", value.Priority);
            IDbDataParameter _priority_param = _cmd.CreateParameter();

            _priority_param.ParameterName = Database.CreateSqlParameterName(TerminationChoiceRow.priority_PropName);
            _priority_param.DbType        = DbType.Byte;
            _priority_param.Direction     = ParameterDirection.Output;
            _cmd.Parameters.Add(_priority_param);

            AddParameter(_cmd, TerminationChoiceRow.routing_plan_id_PropName, value.Routing_plan_id);
            AddParameter(_cmd, TerminationChoiceRow.route_id_PropName, value.Route_id);
            AddParameter(_cmd, TerminationChoiceRow.carrier_route_id_PropName, value.Carrier_route_id);
            AddParameter(_cmd, TerminationChoiceRow.version_PropName, value.Version);


            _cmd.ExecuteNonQuery();

            //object _res = _cmd.ExecuteScalar();
            value.Termination_choice_id = (int)_id_param.Value;
            value.Priority = (byte)_priority_param.Value;

            value.Termination_choice_id = (int)((System.Data.SqlClient.SqlParameter)_cmd.Parameters[_id_param.ParameterName]).Value;
            value.Priority = (byte)((System.Data.SqlClient.SqlParameter)_cmd.Parameters[_priority_param.ParameterName]).Value;
        }
コード例 #3
0
 public bool UpdateInternal(TerminationChoiceRow value)
 {
     return(base.Update(value));
 }