Profiles.Edit.Utilities.DataIO.AddNewEntity C# (CSharp) Méthode

AddNewEntity() public méthode

public AddNewEntity ( string label, string classuri ) : System.Int64
label string
classuri string
Résultat System.Int64
        public Int64 AddNewEntity(string label, string classuri)
        {
            SessionManagement sm = new SessionManagement();
            string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString;

            SqlConnection dbconnection = new SqlConnection(connstr);

            SqlParameter[] param = new SqlParameter[5];

            string error = string.Empty;

            dbconnection.Open();

            param[0] = new SqlParameter("@label", label);
            param[1] = new SqlParameter("@EntityClassURI", classuri);
            param[2] = new SqlParameter("@ForceNewEntity", 1);
            param[3] = new SqlParameter("@SessionID", sm.Session().SessionID);

            param[4] = new SqlParameter("@NodeID", null);
            param[4].DbType = DbType.Int64;
            param[4].Direction = ParameterDirection.Output;

            SqlCommand comm = GetDBCommand(ref dbconnection, "[RDF.].GetStoreNode", CommandType.StoredProcedure, CommandBehavior.CloseConnection, param);

            //For Output Parameters you need to pass a connection object to the framework so you can close it before reading the output params value.
            ExecuteSQLDataCommand(comm);

            comm.Connection.Close();

            if (dbconnection.State == ConnectionState.Open)
                dbconnection.Close();

            return Convert.ToInt64(param[4].Value.ToString());
        }

Usage Example

        private void AddNewEntity()
        {
            Utilities.DataIO data           = new Profiles.Edit.Utilities.DataIO();
            string           newentity      = txtNewEntity.Text.Trim();
            string           entityclassuri = ddlAddNewPropertyList.SelectedValue.Trim();

            Session["pnlAddBySearch.Visible"] = null;
            Session["pnlAddByURI.Visible"]    = null;
            Int64 entityid = 0;

            entityid = data.AddNewEntity(newentity, entityclassuri);

            data.AddExistingEntity(this.SubjectID, this.PredicateID, entityid);

            this.LoadEntityGrid(true);
        }
All Usage Examples Of Profiles.Edit.Utilities.DataIO::AddNewEntity