示例#1
0
        public int Insert(tblMunicipality tblMunicipality)
        {
            int __rowsAffected = 0;

            // Create command
            using (SqlCommand sqlCommand = new SqlCommand("tblMunicipalityInsert"))
            {
                // Set command type
                sqlCommand.CommandType = CommandType.StoredProcedure;

                // Add command parameters
                SqlParameter vid = new SqlParameter("@id", SqlDbType.BigInt);
                vid.Direction = ParameterDirection.InputOutput;
                sqlCommand.Parameters.Add(vid);
                SqlParameter vname = new SqlParameter("@name", SqlDbType.NVarChar, 100);
                vname.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vname);
                SqlParameter vcityId = new SqlParameter("@cityId", SqlDbType.BigInt);
                vcityId.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vcityId);

                // Set input parameter values
                SqlServerHelper.SetParameterValue(
                    vid,
                    tblMunicipality.id,
                    0);
                SqlServerHelper.SetParameterValue(vname, tblMunicipality.name);
                SqlServerHelper.SetParameterValue(vcityId, tblMunicipality.cityId);

                try
                {
                    // Attach command
                    AttachCommand(sqlCommand);

                    // Execute command
                    __rowsAffected = sqlCommand.ExecuteNonQuery();
                    if (__rowsAffected == 0)
                    {
                        return(__rowsAffected);
                    }


                    // Get output parameter values
                    tblMunicipality.id = SqlServerHelper.ToInt64(vid);
                }
                finally
                {
                    // Detach command
                    DetachCommand(sqlCommand);
                }
            }

            return(__rowsAffected);
        }
示例#2
0
        public virtual void Clone(tblMunicipality sourceObject)
        {
            if (sourceObject == null)
            {
                throw new ArgumentNullException("sourceObject");
            }

            // Clone attributes from source object
            this._id     = sourceObject.id;
            this._name   = sourceObject.name;
            this._cityId = sourceObject.cityId;
        }