本文整理汇总了C#中Post.ToEntityReference方法的典型用法代码示例。如果您正苦于以下问题:C# Post.ToEntityReference方法的具体用法?C# Post.ToEntityReference怎么用?C# Post.ToEntityReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post.ToEntityReference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostToPersonalWalls
private void PostToPersonalWalls()
{
Console.WriteLine("\r\n== Working with Personal Walls ==");
// Create manual (user) posts on a user's Personal wall.
var whoAmIRequest = new WhoAmIRequest();
var whoAmIResponse = (WhoAmIResponse)_serviceProxy.Execute(whoAmIRequest);
var currentUserRef = new EntityReference(
SystemUser.EntityLogicalName, whoAmIResponse.UserId);
// Create a post that mentions lead 1.
// The Regarding object should be set to the user whose wall the post should
// be posted to (we'll just use the current user).
_post1 = new Post
{
RegardingObjectId = currentUserRef,
Source = new OptionSetValue((int)PostSource.ManualPost),
Text = String.Format("I'd rather not pursue @[{0},{1},\"{2}\"]",
Lead.EntityTypeCode, _lead1.Id, _lead1.FullName)
};
_serviceContext.AddObject(_post1);
_serviceContext.SaveChanges();
Console.WriteLine(" Personal wall post 1 was created.");
// Create a related comment.
var comment1 = new PostComment
{
PostId = _post1.ToEntityReference(),
Text = "Personal wall comment 1."
};
_serviceContext.AddObject(comment1);
_serviceContext.SaveChanges();
Console.WriteLine(" Personal wall comment 1 was created.");
_post2 = new Post
{
RegardingObjectId = currentUserRef,
Source = new OptionSetValue((int)PostSource.AutoPost),
Text = "Personal wall post 2."
};
_serviceContext.AddObject(_post2);
_serviceContext.SaveChanges();
Console.WriteLine(" Personal wall post 2 was created.");
// Create a few related comments.
var comment2 = new PostComment
{
PostId = _post2.ToEntityReference(),
Text = "Personal wall comment 2."
};
var comment3 = new PostComment
{
PostId = _post2.ToEntityReference(),
Text = "Personal wall comment 3."
};
var comment4 = new PostComment
{
PostId = _post2.ToEntityReference(),
Text = "Personal wall comment 4."
};
var comment5 = new PostComment
{
PostId = _post2.ToEntityReference(),
Text = "Personal wall comment 5."
};
_serviceContext.AddObject(comment2);
_serviceContext.AddObject(comment3);
_serviceContext.AddObject(comment4);
_serviceContext.AddObject(comment5);
_serviceContext.SaveChanges();
Console.WriteLine(" Personal wall comments 2, 3, 4, and 5 were created.");
// Create a couple more posts just to show how paging works.
_post3 = new Post
{
RegardingObjectId = currentUserRef,
Source = new OptionSetValue((int)PostSource.ManualPost),
Text = "Personal wall post 3."
};
_post4 = new Post
{
RegardingObjectId = currentUserRef,
Source = new OptionSetValue((int)PostSource.AutoPost),
Text = "Personal wall post 4."
};
_serviceContext.AddObject(_post3);
_serviceContext.AddObject(_post4);
_serviceContext.SaveChanges();
Console.WriteLine(" Personal wall posts 3 and 4 were created.");
// Retrieve this user's personal wall.
// Retrieve the first page of posts.
//.........这里部分代码省略.........
示例2: PostToRecordWalls
private void PostToRecordWalls()
{
Console.WriteLine("\r\n== Working with Record Walls ==");
// Create the leads.
CreateRequiredRecords();
// Follow each of the leads.
_follow1 = new PostFollow
{
RegardingObjectId = _lead1.ToEntityReference()
};
_serviceContext.AddObject(_follow1);
_follow2 = new PostFollow
{
RegardingObjectId = _lead2.ToEntityReference()
};
_serviceContext.AddObject(_follow2);
_follow3 = new PostFollow
{
RegardingObjectId = _lead3.ToEntityReference()
};
_serviceContext.AddObject(_follow3);
_serviceContext.SaveChanges();
Console.WriteLine(" The 3 leads are now followed.");
// Create posts, mentions, and comments related to the leads.
// Create a post related to lead 1 with a mention and a comment.
_leadPost1 = new Post
{
RegardingObjectId = _lead1.ToEntityReference(),
Source = new OptionSetValue((int)PostSource.AutoPost),
// Include a mention in the post text.
Text = String.Format("This lead is similar to @[{0},{1},\"{2}\"]",
Lead.EntityTypeCode, _lead2.Id, _lead2.FullName)
};
_serviceContext.AddObject(_leadPost1);
_serviceContext.SaveChanges();
Console.WriteLine(" Post 1 has been created.");
// It isn't necessary to keep track of the comment because the comment will
// be deleted when its parent post is deleted.
var comment1 = new PostComment
{
PostId = _leadPost1.ToEntityReference(),
Text = "Sample comment 1"
};
_serviceContext.AddObject(comment1);
_serviceContext.SaveChanges();
Console.WriteLine(" Comment 1 has been created.");
// Create a post related to lead 2 with three comments.
var post2 = new Post
{
RegardingObjectId = _lead2.ToEntityReference(),
Source = new OptionSetValue((int)PostSource.ManualPost),
Text = "This lead was created for a sample."
};
_serviceContext.AddObject(post2);
_serviceContext.SaveChanges();
Console.WriteLine(" Post 2 has been created.");
var comment2 = new PostComment
{
PostId = post2.ToEntityReference(),
Text = "Sample comment 2"
};
var comment3 = new PostComment
{
PostId = post2.ToEntityReference(),
Text = "Sample comment 3"
};
var comment4 = new PostComment
{
PostId = post2.ToEntityReference(),
Text = "Sample comment 4"
};
_serviceContext.AddObject(comment2);
_serviceContext.AddObject(comment3);
_serviceContext.AddObject(comment4);
_serviceContext.SaveChanges();
Console.WriteLine(" Comments 2, 3, and 4 have been created.");
// Qualify some leads. Since there is an active post rule config for
// qualification of a lead, this should generate an auto post to the record
// wall of each lead that is qualified.
// Qualify lead 2.
var qualifyLead2Request = new QualifyLeadRequest
{
CreateAccount = true,
LeadId = _lead2.ToEntityReference(),
Status = new OptionSetValue((int)lead_statuscode.Qualified)
//.........这里部分代码省略.........