nerdexam
Microsoft

70-516 · Question #94

You use Microsoft .NET Framework 4.0 to develop an application that uses WCF Data Services to persist entities from the following Entity Data Model. You create a new Blog instance named newBlog and…

The correct answer is C. newBlog.Posts.Add(newPost). Attaching and Detaching objects

Consuming and Exposing Data

Question

You use Microsoft .NET Framework 4.0 to develop an application that uses WCF Data Services to persist entities from the following Entity Data Model. You create a new Blog instance named newBlog and a new Post instance named newPost as shown in the following code segment. (Line numbers are included for reference only.) 01 Blog newBlog = new Blog(); 02 Post newPost = new Post(); 03 .... 04 Uri serviceUri = new Uri("…"); 05 BlogsEntities context = new BlogsEntities(serviceUri); 06 .... You need to ensure that newPost is related to newBlog through the Posts collection property and that newPost and newBlog are sent to the service. Which code segment should you insert at line 06?

Exhibit

70-516 question #94 exhibit

Options

  • Acontext.AttachLink(newBlog, "Posts", newPost);
  • BnewBlog.Posts.Add(newPost);
  • CnewBlog.Posts.Add(newPost);
  • DnewBlog.Posts.Add(newPost);

How the community answered

(50 responses)
  • A
    4% (2)
  • B
    14% (7)
  • C
    74% (37)
  • D
    8% (4)

Explanation

Attaching and Detaching objects

Topics

#WCF Data Services#AddLink#AddObject#entity relationship

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice