QUESTION 61
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You use the ADO.NET Entity Framework to model your entities. The application connects to a Microsoft SQL Server 2008 database named Adventure Works by using Windows Authentication. Information about the required Entity Data Model (EDM) is stored in the following files:
model.csdl
model.ssdl
model.msi
These files are embedded as resources in the MyCompanyData.dll file.
You need to define the connection string that is used by the application.
Which connection string should you add to the app.config file?
A. |
<add name=”AdventureWorksEntities” connectionString=”metadata=res://MyComparny.Data, Cult ure=neutral,PublicKeyToken=null/model.csdIl res://MyCompany.Data,Culture=neutral, Public KeyToken=null/model.ssdll res://MyCompany.Data,Culture=neutral, PublicKeyToken=null/model.msl; provider=System.Data EntityClient.provider connection string=’DataSource=localhost; Initial Catalog=AdventureWorks;lntegrated Security=True; multipleactivesuitsets=true” providerName=”System.Data.SqlClient”/> |
B. |
<add name=”AdventureWorksEntities” connectionString=”metadata=res://MyComparny.Data,Culture=neutral, PublicKeyToken=nul l/model.csdIl res://MyCompany.Data,Culture=neutral, Public KeyToken=null/model.ssdll res: //MyCompany.Data,Culture=neutral, PublicKeyToken =null/model.msl; provider=System.Data EntityClient.provider connection string=’DataSource=localhost; Initial Catalog=AdventureWorks;lntegrated Security=True; multipleactivesuitsets=true” providerName=”System.Data.EntityClient”/> |
C. |
<add name=”AdventureWorksEntities” connectionString=”metadata=res://MyComparny.Datamodel.csdl| res://MyCompany.Data.model.ssdl| res://MyComparny.Datamodel.msi; provider=System.Data.SqlClient.provider Initial Catalog=AdventureWorks;lntegrated Security=SSPI; multipleactivesuitsets=true” providerName=”System.Data.EntityClient”/> |
D. |
<add name=”AdventureWorksEntities” connectionString=”metadata=res://MyComparny.Data,Culture=neutral,PublicKeyToken= null/model.csdIl res://MyComparny.Data,Culture=neutral,PublicKeyToken=null/model.ssdIl res://MyComparny.Data,Culture=neutral,PublicKeyToken=null/model.msi; provider=System.Data.OleDBClient.provider connection string=’Provider=sqloledb;DataSource=localhost; Initial Catalog=AdventureWorks; lntegrated Security=SSPI;multipleactivesuitsets=true” providerName=”System.Data.EntityClient”/> |
Correct Answer: B
Explanation:
Answering this question pay attention to fact that Entity Framework is used, so settings
provider=”System.Data.SqlClient” and providerName=”System.Data.EntityClient” shold be set.
Connection Strings
http://msdn.microsoft.com/en-us/library/cc716756.aspx
QUESTION 62
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application.You use the ADO.NET Entity Framework to model your entities.You use Plain Old CLR Obects (POCO) entities along with snapshot-based change tracking. The code accesses the POCO entries direcly.
You need to ensure that the state manager synchronizes when changes are made to the object graph.
Which ObectContext method should you choose?
A. |
Refresh |
B. |
SaveChanges |
C. |
DetectChanges |
D. |
ApplyPropertyChanges |
Correct Answer: C
Explanation:
When working with POCO, you must call the DetectChanges method on the ObjectContext to attach the POCO entity to the ObjectContext. Be sure to call DetectChanges prior to calling SaveChanges.
ApplyPropertyChanges Obsolete. Applies property changes from a detached object to an object already attached to the object context.
CHAPTER 6 ADO.NET Entity Framework
Lesson 2: Querying and Updating with the Entity Framework Attaching Entities to an ObjectContext (page 438)
QUESTION 63
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server 2008 database.
The application uses a Microsoft ADO.NET SQL Server managed provider. When a connection fails, the application logs connection information, including the full connection string. The information is stored as plain text in a .config file.
You need to ensure that the database credentials are secure.
Which connection string should you add to the .config file?
A. |
Data Source=myServerAddress; Initial Catalog=myDataBase; Integrated Security=SSPI; Persist Security Info=true; |
B. |
Data Source=myServerAddress; Initial Catalog=myDataBase; User Id = myUsername; Password = myPassword; Persist Security Info=false; |
C. |
Data Source=myServerAddress; Initial Catalog=myDataBase; Integrated Security=SSPI; Persist Security Info=false; |
D. |
Data Source=myServerAddress; Initial Catalog=myDataBase; User Id = myUsername; Password = myPassword; Persist Security Info=true; |
Correct Answer: C
Explanation:
Persist Security Info
Default: ‘false’
When set to false or no (strongly recommended), security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state. Resetting the connection string resets all connection string values including the password.
Recognized values are true, false, yes, and no.
QUESTION 64
You use Microsoft .NET Framework 4 to develop an application. You write the following code to update data in a Microsoft SQL Server 2008 database. (Line numbers are included for reference only.)
01 private void ExecuteUpdate (SqlCoiranand cmd,
string connString, string updateStrnt)
02 {
03
04 }
You need to ensure that the update statement executes and that the application avoids connection leaks.
Which code segment should you insert at line 03?
A. |
SqlConnection conn = new SqlConnection(connString) ; conn. Open (); cmd.Connect ion = conn; cmd.CommandText = updateStmt; cmd.ExecuteNonQuery(); cmd.Connection.Close() ; |
B. |
using (SqlConnection conn = new SqlConnection(connString)) } cmd.Connection = conn; cmd.CommandText = updateStmt; cmd.ExecuteNonQuery(); cmd.Connection.Close(); } |
C. |
using (SqlConnection conn = new SqlConnection(connString) ) { conn.Open() ; cmd.Connection = conn; cmd.CommandText = updateStmt; cmd.ExecuteNonQuery() ; } |
D. |
SqlConnection conn = new SqlConnection(connString); conn. Open (); cmd.Connection = conn; cmd.CommandText = updateStmt; cmd.ExecuteNonQuery(); |
Correct Answer: C
Explanation:
http://stackoverflow.com/questions/376068/does-end-using-close-an-open-sql-connection
http://www.w3enterprises.com/articles/using.aspx
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx
QUESTION 65
You use Microsoft .NET Framework 4 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 = neu Blog();
02 Post neuPost = neu Post ();
03 –
04 Uci 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?
A. |
context.AttachLink(newBlog, “Posts”, newPost); context.SaveChanges(SaveChangesOptions.Batch); |
B. |
newBlog.Posts.Add(newPost); context.AddToBlogs(newBlog); context.AddToPosts(newPost); context.SaveChanges(SaveChangesOptions.Batch); |
C. |
newBlog.Posts.Add(newPost); context.AttachTo(“Blogs”, newBlog); context.AttachTo(“Posts”, newPost); context.SaveChanges(SaveChangesOptions.Batch); |
D. |
newBlog.Posts.Add(newPost); context.UpdateObject(newBlog); context.UpdateObject(newPost); context.SaveChanges(SaveChangesOptions.Batch); |
Correct Answer: C
Explanation:
Attaching and Detaching objects
http://msdn.microsoft.com/en-us/library/bb896271.aspx
QUESTION 66
HOTSPOT
You create an Entity Data Model (EDM) named ModelContoso.
You need to generate a Transact-SQL script to create a database to store ModelContoso. The solution must ensure that table names are prefixed automatically with TBL_.
Which property of ModelContoso should you modify?
To answer, select the appropriate property in the answer area.
Correct Answer:
QUESTION 67
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Windows Communication Foundation (WCF) Data Services service.
You discover that when an application submits a PUT or DELETE request to the Data Services service, it receives an error.
You need to ensure that the application can access the service.
Which header and request type should you use in the application?
A. |
an X-HTTP-Method header as part of a POST request |
B. |
an X-HTTP-Method header as part of a GET request |
C. |
an HTTP ContentType header as part of a POST request |
D. |
an HTTP ContentType header as part of a GET request |
Correct Answer: A
Explanation:
The X-HTTP-Method header can be added to a POST request that signals that the server MUST process the request not as a POST, but as if the HTTP verb specified as the value of the header was used as the method on the HTTP request’s request line, as specified in [RFC2616] section 5.1. This technique is often referred to as “verb tunneling”. This header is only valid when on HTTP POST requests.
X-HTTPMethod
http://msdn.microsoft.com/en-us/library/dd541471(v=prot.10).aspx
QUESTION 68
You use Microsoft .NET Framework 4 to develop an application that uses LINQ to SQL.
You create a data model named AdvWorksDataContext, and you add the Product table to the data model. The Product table contains a decimal column named ListPrice and a string column named Color.
You need to update the ListPrice column where the product color is Black or Red.
Which code segment should you use?
A. |
string[] colorList = new string[] {“Black”,”Red”}; AdvWorksDataContext dc = new AdvWorksDataContext(); var prod = from p in dc.Products where colorList.Contains(p.Color) select p; foreach (var product in prod) { product.ListPrice = product.StandardCost * 1.5M; } dc.SubmitChanges(); |
B. |
AdvWorksDataContext dc = new AdvWorksDataContext( “& ” ); var prod = from p in dc.Products select p; var list = prod.ToList(); foreach (Product product in list) { if (product.Color == “Black,Red”) { product.ListPrice = product.StandardCost * 1.5M; } } dc.SubmitChanges(); |
C. |
AdvWorksDataContext dc = new AdvWorksDataContext( “& ” ); var prod = from p in dc.Products where p.Color == “Black,Red” select p; foreach (var product in prod) { product.ListPrice = product.StandardCost * 1.5M; } dc.SubmitChanges(); |
D. |
AdvWorksDataContext dc = new AdvWorksDataContext( “& ” ); var prod = from p in dc.Products select p; var list = prod.ToList(); foreach (Product product in list) { if ((product.Color == “Black”)&&(product.Color == “Red”)) { product.ListPrice = product.StandardCost * 1.5M; } } dc.SubmitChanges(); |
Correct Answer: A
QUESTION 69
DRAG DROP
You are developing a Microsoft .NET Framework 4 application. The application connects to a Microsoft SQL Server database. You have the following stored procedure:
You have a custom class named CustomerDataContext that is derived from the DataContext class.
You need to use an instance of CustomerDataContext to update the database.
What code should you use?
To answer, drag the appropriate code segments to the correct locations. Each code segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.
Correct Answer:
QUESTION 70
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server database. You use the ADO.NET Entity Framework to manage persistence-ignorant entities.
You create an ObjectContext instance named context. Then, you directly modify properties on several entities.
You need to save the modified entity values to the database.
Which code segment should you use?
A. |
context.SaveChanges(SaveOptions.AcceptAllChangesAfterSave); |
B. |
context.SaveChanges(SaveOptions.DetectChangesBeforeSave); |
C. |
context.SaveChanges(SaveOptions.None); |
D. |
context.SaveChanges(); |
Correct Answer: B
Explanation:
None Changes are saved without the DetectChanges or the AcceptAllChangesAfterSave() methods being called. AcceptAllChangesAfterSave After changes are saved, the AcceptAllChangesAfterSave() method is called, which resets change tracking in the ObjectStateManager. DetectChangesBeforeSave Before changes are saved, the DetectChanges method is called to synchronize the property values of objects that are attached to the object context with data in the ObjectStateManager.
SaveOptions Enumeration
http://msdn.microsoft.com/en-us/library/system.data.objects.saveoptions.aspx
Free VCE & PDF File for Microsoft 70-516 Real Exam
Instant Access to Free VCE Files: MCSE|MCSA|MCITP…
Instant Access to Free PDF Files: MCSE|MCSA|MCITP…
70-410 Dumps VCE PDF
70-411 Dumps VCE PDF
70-412 Dumps VCE PDF
70-413 Dumps VCE PDF
70-414 Dumps VCE PDF
70-417 Dumps VCE PDF
70-461 Dumps VCE PDF
70-462 Dumps VCE PDF
70-463 Dumps VCE PDF
70-464 Dumps VCE PDF
70-465 Dumps VCE PDF
70-480 Dumps VCE PDF
70-483 Dumps VCE PDF
70-486 Dumps VCE PDF
70-487 Dumps VCE PDF