News:

SQL Table To C# Entity Model ConverterEntity Model (Class Properties) to SQL Table ConverterIf you encounter any trouble visiting our site, please contact us.

MCPD- Exam 70-516: Accessing Data with Microsoft .NET Framework 4

Exibit:

  1. using (NorthwindDatacontext dc =new northwinddataContext()
    {
    dc.objectTrackingenabled=false;
    var catgories from c in dc Categories select C;
    for each (var category in categones)
    {
    Console.Writeline({0} has {1} product, category.CategoryNe. categoy ProcductsCount);
    }
    }
  2. using (NorthwindDataContext dc new northwinddataContext)
    {
    dc DeferredLoadingEnabled = false;
    DataLoadopions dIoption = new DataLoadoption()
    Dloptions.LoadWith category(c => c. Products);
    dc.LoadOpions dlOptions;
    var category from c in dc Categories select c;
    foreach (var category in categories)
    {
    Console.Writeline({0} has {1} product, category.CategoryName. category.Procducts.Count);
    }
    }
  3. using (NorthwindDataContext dc = new northwindDataContext())
    dc.deferrwsloading enabled=false;
    var categories = from c m dcCategories select c,
    foreach(var Category in categories}
    Consie Writetineç(O) as (1) products, category CategocyName, category.Products
    Count)))
  4. using (NorthwindDataContext dc = new northwindDataContext()) {
    dc deferredloadingenabled = false;
    dataLoadOprions dioptions = new dataLnadOptions();
    dlOptcnsAssociateWith category(c=>c.Products)
    dc.loadoptions = dlOptions;
    var categories=from c in dc Calegories select c;
    foreach (var category in categories)
    {
    Console.Writeline({0} has {1} product, category.CategoryName. category.Procducts.Count);
    }
    }
Answer: Answer is b

“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?

  1. <add name=”AdventureWorksEntities” connectionString=”metadata=res://MyComparny.Data, Culture=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”/>
  2. <add name=”AdventureWorksEntities” connectionString=”metadata=res://MyComparny.Data, Culture=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.EntityClient”/>

  3. <add name=”AdventureWorksEntities” connectionString=”metadata=res://MyComparny.Datamodel.csdl| res://MyCompany.Data.model.ssdl| res://MyComparny.Datamodel.msi; provider=System.Data.SqlClient.provider connection string=’DataSource=localhost; Initial Catalog=AdventureWorks;lntegrated Security=SSPI;multipleactivesuitsets=true” providerName=”System.Data.EntityClient”/>
  4. <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”/>
Answer: Answer is b

CREATE TABLE [Sales].[SalesOrderHeader](
[SalesOrdedD] [int] IDENTITY(1,1)NOT NULL,
(BillToAddressID][int] NOT NULL,
^CONSTRAINT [PK_SalesOrderHeader_SalesOrder1D]
PRIMARY KEY CLUSTERED ([SalesOrder1D]ASC)
)ALTER TABLE [Sales].[SalesOrderHeader] WITH CHECK ADD CONSTRAINT [FK_SalesOrderHeader_Address]
FOREIGN KEY{[BilIToAddressID])
REFERENCES [Person] [Address](AddressID])

You create an ADO.NET Entity Framework model.You need to ensure that the entities of the model correctly map to the DDL of the database. What should your model contain?

Answer: Answer is a

  1. Stopwatch stopWatch = new Stopwatch();
    stopWatch.Start();
    DoSomething();
    stopWatch.Stop();
    TimeSpan ts = stopWatch.Elapsed;
    string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
    Console.WriteLine(elapsedTime, "RunTime");
    private void DoSomething()
    { ... }
  2. Stopwatch stopWatch = new Stopwatch();
    stopWatch.Start();
    DoSomething();
    stopWatch.Reset();
    TimeSpan ts = stopWatch.Elapsed;
    string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.
    Milliseconds / 10);
    Console.WriteLine(elapsedTime, "RunTime");
    private void DoSomething()
    { ... }
  3. ...Stopwatch stopWatch = new Stopwatch();
    stopWatch.Start();
    DoSomething();
    TimeSpan ts = stopWatch.Elapsed;
    string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.
    Milliseconds / 10);
    Console.WriteLine(elapsedTime, "RunTime");
    private void DoSomething()
    { ... }
  4. Stopwatch stopWatch = new Stopwatch();
    stopWatch.Begin();
    DoSomething();
    stopWatch.End();
    TimeSpan ts = stopWatch.Elapsed;
    string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.
    Milliseconds / 10);
    Console.WriteLine(elapsedTime, "RunTime");
    private void DoSomething()
    { ... }
Answer: Answer is a

If INSERTs into the first table succeed, then INSERT into the second table. However, if the INSERTs into the
second table fail, roll back the inserts in the second table but do not roll back the inserts in the first table.
Although this can also be done by way of regular transactions, It needs to be performed using
TransactionScope objects.

Whis code would fit this business rule?

  1. try
    {
    using (TransactionScope scope1 = new TransactionScope(TransactionScopeOption){
    ....
    try
    {
    .....
    using (TransactionScope scope2 = new TransactionScope(TransactionScopeOption))
    { .... }
    }
  2. try
    {
    using (TransactionScope scope1 = new TransactionScope(TransactionScopeOption.Required))
    {
    ...
    using (TransactionScope scope2 = new TransactionScope(TransactionScopeOption. RequiresNew))
    { .... }
    ......
    }
  3. try
    {
    using (TransactionScope scope1 = new TransactionScope(TransactionScopeOption.Required))
    {
    ...
    }
    using (TransactionScope scope2 = new TransactionScope(TransactionScopeOption.RequiresNew))
    {
    ....
    }
    }
  4. try
    {
    using (TransactionScope scope1 = new TransactionScope(TransactionScopeOption.Required))
    {
    ....
    try
    {
    .....
    using (TransactionScope scope2 = new TransactionScope(TransactionScopeOption. RequiresNew))
    { .... }
    }
Answer: Answer is d

  1. doc.DescendantNodes();

  2. doc.Descendant();

  3. doc.Root.Allnodes();

  4. doc.GetAllnodes();

Answer: Answer is a

  1. SqlDataReader rdr = new SqlDataReader();
    string sql = @"sql statement";
    SqlConnection conn = connection.GetConnection();
    SqlCommand cmd = new SqlCommand(sql, conn);
    SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
    Console.WriteLine("{0}", rdr);
  2. SqlDataReader rdr = new SqlDataReader();
    string sql = @"sql statement";
    SqlConnection conn = connection.GetConnection();
    SqlCommand cmd = new SqlCommand(sql, conn);
    SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
    rdr.close();
    Console.WriteLine("{0}", rdr);
  3. SqlDataReader rdr = new SqlDataReader();
    string sql = @"sql statement";
    SqlConnection conn = connection.GetConnection();
    SqlCommand cmd = new SqlCommand(sql, conn);
    SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
    conn.close();
    Console.WriteLine("{0}", rdr);
  4. using (SqlDataReader rdr = new SqlDataReader())
    {
    string sql = @"sql statement";
    SqlConnection conn = connection.GetConnection();
    SqlCommand cmd = new SqlCommand(sql, conn);
    SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
    Console.WriteLine("{0}", rdr);
    }
Answer: Answer is b

Which answer belongs in line 09?

01 Using SqlConnection cnx = New SqlConnection(connString) {
02 var command = cnx.CreateCommand()
03 command.CommandType = CommandType.Text
04 command.CommandText = "SELECT TOP 1 * FROM dbo.ProductCatalog"
05 cnx.Open()
06 var reader = command.ExecuteReader()
07 If ( reader.Read()) {
08 var id = reader.GetInt32(0)
10 reader.Close()
11 }
12 }

  1. var weight = reader.GetDouble(1)
    var price = reader.GetDecimal(2)
    var status = reader.GetBoolean(3)
  2. var weight = reader.GetFloat(1)
    var price = reader.GetDecimal(2)
    var status = reader.GetByte(3)
  3. var weight = reader.GetDouble(1)
    var price = reader.GetFloat(2)
    var status = reader.GetBoolean(3)
  4. var weight = reader.GetFloat(1)
    var price = reader.Doublel(2)
    var status = reader.GetByte(3)
Answer: Answer is a

01 using (EntityCommand cmd = conn.CreateCommand())
02 {03 cmd.CommandText = esqlQuery;
04 EntityParameter param = new EntityParameter();
05 param.ParameterName = "id";
06 param.Value = 3;
07 cmd.Parameters.Add(param);
08 using (EntityDataReader rdr = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
09 {
10 while (rdr.Read())
11 {
12
13 Console.WriteLine("Email and Phone Info:");
14 for (int i = 0; i < nestedRecord.FieldCount; i++)
15 {
16 Console.WriteLine(" " + nestedRecord.GetName(i) + ": " + nestedRecord.GetValue(i));
17 }
18 }
19 }
  1. DbDataRecord nestedRecord = rdr["EmailPhoneComplexProperty"] as DbDataRecord;
  2. DbDataRecord nestedRecord = rdr["EmailPhoneComplexProperty"]
  3. DataSet nestedRecord = rdr["EmailPhoneComplexProperty"] as ComplexDataSet
  4. ComplexDataRecord nestedRecord = rdr["EmailPhoneComplexProperty"]
Answer: Answer is a

Exhibit:

  1. var query = leagues.Select(l => l.Teams.Select(t => t.Players));
  2. var query = leagues.Select(l => l.Teams.SelectMany(t => t.Players));
  3. var query = leagues.SelectMany(l => l.Teams.SelectMany(t => t.Players));
  4. var query = leagues.SelectMany(l => l.Teams.Select(t => t.Players));
Answer: Answer is c