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

01 public class Category
02 {
03 public int CategoryID { get; set; }
04 public string CategoryName { get; set; }
05 public string Description { get; set; }
06 public byte[] Picture { get; set; }
07
08 }

You need to add a collection named Products to the Category class. You also need to ensure that the collection supports deferred loading. Which code segment should you insert at line 07?

  1. public static List <Product> Products { get; set; }
  2. public virtual List <Product> Products { get; set; }
  3. public abstract List <Product> Products { get; set; }
  4. protected List <Product> Products { get; set; }
Answer: Answer is b

01Configuration config = ConfigurationManager.OpenExeConfiguration(exeConfigName);
02
03config.Save();
04...

You need to encrypt the connection string stored in the .config file. Which code segment should you insert at line 02?

  1. ConnectionStringsSection section = config.GetSection("connectionString") as ConnectionStringsSection; section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
  2. ConnectionStringsSection section = config.GetSection("connectionStrings") as ConnectionStringsSection; section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
  3. ConnectionStringsSection section = config.GetSection("connectionString") as ConnectionStringsSection; section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
  4. ConnectionStringsSection section = config.GetSection("connectionStrings") as ConnectionStringsSection; section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
Answer: Answer is d

01 using (AdventureWorksEntities context = new AdventureWorksEntities()){
02
03 foreach (SalesOrderHeader order in customer.SalesOrderHeader){
04Console.WriteLine(String.Format("Order: {0} ", order.SalesOrderNumber));
05 foreach (SalesOrderDetail item in order.SalesOrderDetail){
06Console.WriteLine(String.Format("Quantity: {0} ", item.Quantity));
07Console.WriteLine(String.Format("Product: {0} ", item.Product.Name));
08}
09}
10}

You want to list all the orders for a specified customer. You need to ensure that the list contains the following fields: "Order number "Quantity of products "Product name Which code segment should you insert at line 02?

  1. Contact customer = context.Contact.Where("it.ContactID = @customerId", new ObjectParameter ("@customerId", customerId)).First();
  2. Contact customer = context.Contact.Where("it.ContactID = @customerId", new ObjectParameter ("customerId", customerId)).First();
  3. context.ContextOptions.LazyLoadingEnabled = true; Contact customer = (From contact in context.Contact include("SalesOrderHeader.SalesOrderDetail") select conatct). FirstOrDefault();
  4. Contact customer = (From contact in context.Contact include("SalesOrderHeader") select conatct). FirstOrDefault();
Answer: Answer is b

01AdventureWorksEntities context = New AdventureWorksEntities (http://localhost:1234/AdventureWorks.
svc );
02
03var q = from c in context.Customers
04where c.City == "London"
05orderby c.CompanyName
06select c;

You need to ensure that the application meets the following requirements: "Compares the current values of unmodified properties with values returned from the data source. "Marks the property as modified when the properties are not the same. Which code segment should you insert at line 02?

  1. context.MergeOption = MergeOption.AppendOnly;
  2. context.MergeOption = MergeOption.PreserveChanges;
  3. context.MergeOption = MergeOption.OverwriteChanges;
  4. context.MergeOption = MergeOption.NoTracking;
Answer: Answer is b

01public partial class SalesOrderDetail : EntityObject
02{
03partial void OnOrderQtyChanging(short value)
04{
05
06{
07...
08}
09}
10}

You need to find out whether the object has a valid ObjectStateEntry instance. Which code segment should you insert at line 05?

  1. if (this.EntityState != EntityState.Detached)
  2. if (this.EntityState != EntityState.Unchanged)
  3. if (this.EntityState != EntityState.Modified)
  4. if (this.EntityState != EntityState.Added)
Answer: Answer is d

01SyncTable customerSyncTable = new SyncTable("Customer");
02customerSyncTable.CreationOption = TableCreationOption. UploadExistingOrCreateNewTable;
03
04customerSyncTable.SyncGroup = customerSyncGroup;
05 this.Configuration.SyncTables.Add(customerSyncTable);

You need to ensure that the application meets the following requirements: "Users can modify data locally and receive changes from the server. "Only changed rows are transferred during synchronization. Which code segment should you insert at line 03?

  1. customerSyncTable.SyncDirection = SyncDirection.DownloadOnly;
  2. customerSyncTable.SyncDirection = SyncDirection.Snapshot;
  3. customerSyncTable.SyncDirection = SyncDirection.Bidirectional;
  4. customerSyncTable.SyncDirection = SyncDirection.UploadOnly;
Answer: Answer is c

  1. Add the following line of code to the InitializeService method of the service.

    config.SetEntitySetAccessRule ("*",EntitySetRights.WriteDelete | EntitySetRights.WriteInsert);
  2. Add the following line of code to the InitializeService method of the service.

    config.SetEntitySetAccessRule ("*",EntitySetRights.WriteDelete | EntitySetRights.WriteMerge);
  3. Configure IIS to allow the PUT and DELETE verbs for the .svc Application Extension.

  4. Configure IIS to allow the POST and DELETE verbs for the .svc Application Extension.

Answer: Answer is c

01public void LoadDocuments(DbConnection cnx)
02{
03var cmd = cnx.CreateCommand();
04cmd.CommandText = "SELECT * FROM dbo.Documents";
05...
06cnx.Open();
07
08ReadDocument(reader); }

You need to ensure that data can be read as a stream. Which code segment should you insert at line 07?

  1. var reader = cmd.ExecuteReader(CommandBehavior.Default);
  2. var reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly);
  3. var reader = cmd.ExecuteReader(CommandBehavior.KeyInfo);
  4. var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess);

Answer: Answer is d

01public void Fill(SqlConnection cnx, DataSet ds) {
03var cmd = cnx.CreateCommand();
04cmd.CommandText = "SELECT * FROM dbo.Products; " + "SELECT * FROM dbo.Categories";
05var adapter = new SqlDataAdapter(cmd);
06
07}

You need to ensure that App_Products and App_Categories are populated from the dbo.Products and dbo.
Categories database tables. Which code segment should you insert at line 06?

  1. adapter.Fill(ds, "Products"); adapter.Fill(ds, "Categories");
  2. adapter.Fill(ds.Tables["App_Products"]);
    adapter.Fill(ds.Tables["App_Categories"]);
  3. adapter.TableMappings.Add("Table", "App_Products");
    adapter.TableMappings.Add("Table1", "App_Categories");
    adapter.Fill(ds);
  4. adapter.TableMappings.Add("Products", "App_Products");
    adapter.TableMappings.Add("Categories", "App_Categories");
    adapter.Fill(ds);
Answer: Answer is c

01var uri = new Uri(@"http://contoso.com/Northwind.svc/");
02var ctx = new NorthwindEntities(uri);
03var categories = from c in ctx.Categories 04select c;
04foreach (var category in categories) {
05PrintCategory(category);
06
07foreach (var product in category.Products) {
08
09PrintProduct(product);
10}
11}

You need to ensure that the Product data for each Category object is lazy-loaded. What should you do?

  1. Add the following code segment at line 06.

    ctx.LoadProperty(category, "Products");
  2. Add the following code segment at line 08.

    ctx.LoadProperty(product, "*");
  3. Add the following code segment at line 06.

    var strPrdUri = string.Format("Categories({0})?$expand=Products", category.CategoryID);
    var productUri = new Uri(strPrdUri, UriKind.Relative);
    ctx.Execute <Product>(productUri);

     

  4. Add the following code segment at line 08.

    var strprdUri= string.format("Products?$filter=CatgoryID eq {0}", category.CategoryID);
    VarProdcutUri = new Uri(strPrd, UriKind.Relative);
    ctx.Execute <Product>(productUri);
Answer: Answer is a

Advertisement

BCS Preparation now even more easy. ReadBD is the place where you can find all kind of resources to be successful in BCS,Bank,Islami Bank exam and interview.

Looking for job. Try JobLoader- First ever job search engine in Bangladesh. All open bd jobs now a single mouse click away.

;