G'day Jay and welcome to the world of CRM
Firstly you might want to post this in the CRM Development forum as its not really a CRM Deployment question.
Jay you should probably have a look at the CRM SDK
http://msdn.microsoft.com/en-us/library/hh547453(v=crm.5).aspx
Its an invaluable resource with all the information you could ever consider & sometimes it even makes sense.
Have a look at the Sample Code section
http://msdn.microsoft.com/en-us/library/gg309721(v=crm.5).aspx you should find enough examples to help you along.
To retrieve a single account record:
var acct = Service.Retrieve("account", <Guid of Account to retrieve>, <Columns to Retrieve from Account entity>)
To retrieve a single staff record:
var qry = new QueryExpression("relationship") {
PageInfo = new PagingInfo() { ReturnTotalRecordCount = true }
,
ColumnSet = <Columns to Return from Relationship entity>
,
Criteria = new FilterExpression(LogicalOperator.And) {
Conditions = {
new ConditionExpression("description", ConditionOperator.BeginsWith, "staff") // this performs the 'staff%'
}
}
};
var qryRslts = Service.RetrieveMultiple(qry);
var entityRelationship = qryRslts.TotalRecordCount > 0 ? qryRslts[0] : null;
To retrieve Contacts you can use another QueryExpression with the appropriate Conditions limiting the results returned to those you want
Then to create a new record for contactrelationship :
var ctRel = new Entity("contactrelationship");
ctRel.Attributes.Add("relationshipid", new EntityReference("relationship", entityRelationship .Id);
ctRel.Attributes.Add("contactid ", new EntityReference("contact", contact.Id); // note contact comes from the Contacts QueryExpression
ctRel.Attributes.Add("organizationid", new EntityReference("account", acct .Id);
Service.Create(ctRel)
Hope this gives you a start & good luck