static public void AddProfileValue(int PortalId, int staffId, string propertyName, string propertyValue, int Type = 0)
    {
        StaffBrokerDataContext      d      = new StaffBrokerDataContext();
        AP_StaffBroker_StaffProfile insert = new AP_StaffBroker_StaffProfile();
        var definition = (from c in d.AP_StaffBroker_StaffPropertyDefinitions where c.PropertyName == propertyName && c.PortalId == PortalId select c.StaffPropertyDefinitionId);

        if (definition.Count() == 0)
        {
            AP_StaffBroker_StaffPropertyDefinition newDef = new AP_StaffBroker_StaffPropertyDefinition();
            newDef.PortalId     = PortalId;
            newDef.PropertyName = propertyName;
            newDef.Display      = false;
            newDef.ViewOrder    = (short?)((from c in d.AP_StaffBroker_StaffPropertyDefinitions where c.PortalId == PortalId select c.ViewOrder).Max() + 1);
            newDef.Type         = Convert.ToByte(Type);


            newDef.PropertyHelp = "";
            d.AP_StaffBroker_StaffPropertyDefinitions.InsertOnSubmit(newDef);
            d.SubmitChanges();
            insert.StaffPropertyDefinitionId = newDef.StaffPropertyDefinitionId;
        }
        else
        {
            insert.StaffPropertyDefinitionId = definition.First();
        }

        insert.StaffId       = staffId;
        insert.PropertyValue = propertyValue;
        var existing = from c in d.AP_StaffBroker_StaffProfiles where c.StaffId == insert.StaffId && c.StaffPropertyDefinitionId == insert.StaffPropertyDefinitionId select c;

        if (existing.Count() > 0)
        {
            existing.First().PropertyValue = propertyValue;
        }
        else
        {
            d.AP_StaffBroker_StaffProfiles.InsertOnSubmit(insert);
        }

        d.SubmitChanges();
    }
    public static void AddProfileValue(int PortalId, int staffId, string propertyName, string propertyValue, int Type = 0)
    {
        StaffBrokerDataContext d = new StaffBrokerDataContext();
        AP_StaffBroker_StaffProfile insert = new AP_StaffBroker_StaffProfile();
        var definition = (from c in d.AP_StaffBroker_StaffPropertyDefinitions where c.PropertyName == propertyName && c.PortalId == PortalId select c.StaffPropertyDefinitionId);
        if (definition.Count() == 0)
        {
            AP_StaffBroker_StaffPropertyDefinition newDef = new AP_StaffBroker_StaffPropertyDefinition();
            newDef.PortalId = PortalId;
            newDef.PropertyName = propertyName;
            newDef.Display = false;
            newDef.ViewOrder = (short?)((from c in d.AP_StaffBroker_StaffPropertyDefinitions where c.PortalId == PortalId select c.ViewOrder).Max() + 1);
            newDef.Type = Convert.ToByte(Type);

            newDef.PropertyHelp = "";
            d.AP_StaffBroker_StaffPropertyDefinitions.InsertOnSubmit(newDef);
            d.SubmitChanges();
            insert.StaffPropertyDefinitionId = newDef.StaffPropertyDefinitionId;
        }
        else
            insert.StaffPropertyDefinitionId = definition.First();

        insert.StaffId = staffId;
        insert.PropertyValue = propertyValue;
        var existing = from c in d.AP_StaffBroker_StaffProfiles where c.StaffId == insert.StaffId && c.StaffPropertyDefinitionId == insert.StaffPropertyDefinitionId select c;

        if (existing.Count() > 0)
            existing.First().PropertyValue = propertyValue;
        else
            d.AP_StaffBroker_StaffProfiles.InsertOnSubmit(insert);

        d.SubmitChanges();
    }