1 / 12

Introduction to C# and Databases - Homework

Introduction to C# and Databases - Homework. Doncho Minkov. Technical Trainer. http://www.minkov.it. Telerik School Academy. schoolacademy.telerik.com. C# Overview.

santo
Download Presentation

Introduction to C# and Databases - Homework

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to C# and Databases - Homework Doncho Minkov Technical Trainer http://www.minkov.it Telerik School Academy schoolacademy.telerik.com

  2. C# Overview • Write a program that, for a given two integer numbers N and X, calculates the sumS = 1 + 1!/X + 2!/X2 + … + N!/XN • Write a program that reads a number N and calculates the sum of the first N members of the sequence of Fibonacci: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, … Each member of the Fibonacci sequence (except the first two) is a sum of the previous two members. • Write a program that calculates the greatest common divisor (GCD) of given two numbers. Use the Euclidean algorithm (find it in Internet).

  3. C# Overview (2) • Write a program that fills a matrix of size (N, N) as shown in the examples (for N=4): a) b) *c) *d)

  4. C# Overview (3) • * Write a program that converts a number in the range [0...999] to a text corresponding to its English pronunciation. Examples: 0  "Zero" 273  "Two hundred seventy three" 400  "Four hundred" 501  "Five hundred and one" 711  "Severn hundred and eleven"

  5. C# Overview (4) • Write a program that reads a list of words, separated by spaces and prints the list in an alphabetical order. • Write a program to check if in a given expression the brackets are put correctly. Example of correct expression: ((a+b)/5-d). Example of incorrect expression: )(a+b)). • Write a program that generates and prints to the console 10 random values in the range [100,200]. • Write a program that prints to the console which day of the week is today. Use System.DateTime.

  6. C# Overview (5) • Write a program that parses an URL address given in the format: and extracts from it the [protocol], [server]and[resource] elements. For example from the URL http://www.devbg.org/forum/index.phpthe following information should be extracted: [protocol] = "http" [server] = "www.devbg.org" [resource] = "/forum/index.php" [protocol]://[server]/[resource]

  7. C# OOP • We are given a library of books. Define classes for the library and the books. The library should have name and a list of books. The books have title, author, publisher, year of publishing and ISBN. Keep the books in List<Book> (first find how to use the class System.Collections.Generic.List<T>). • Implement methods for adding, searching by title and author, displaying and deleting books. • Write a test class that creates a library, adds few books to it and displays them. Find all books by Nakov, delete them and print again the library.

  8. LINQ • Create a class student with properties FirstName, LastName, FN, Tel, Email, Marks(aList<int>), GroupNumber. Create a List<Student> with sample students. Select only the students that are from group number 2. Use LINQ query. Order the students by FirstName. • Implement the previous using the same query expressed with extension methods. • Extract all students that have email in abv.bg. Use string methods and LINQ. • Extract all students with phones in Sofia. Use LINQ and regular expressions.

  9. LINQ (2) • Select all students that have at least one mark Excellent (6) into a new anonymous class that has properties – FullName and Marks. Use LINQ. • Write down a similar program that extracts the students with exactly two marks "2". Use extension methods. • Extract all Marksof the students that enrolled in 2006. (The students from 2006 have 06 as their 5-th and 6-th digit in the FN). • Create a program that extracts all students grouped by GroupName and then prints them to the console. Use LINQ.

  10. Entity Framework • Using the Visual Studio Entity Framework designer create a ObjectContext for the Northwind database • Create a DAO class with static methods which provide functionality for inserting, modifying and deleting customers. Write a testing class. • Write a method that finds all customers who have orders made in 1997 and shipped to Canada. • Implement previous by using native SQL query and executing it through the ObjectContext. • Write a method that finds all the sales by specified region and period (start / end dates).

  11. Entity Framework (2) • Create a database called NorthwindTwin with the same structure as Northwind using the features from ObjectContext. Find for the API for schema generation in MSDN or in Google. • Try to open two different data contexts and perform concurrent changes on the same records. What will happen at SaveChanges()? How to deal with it? • By inheriting the Employee entity class create a class which allows employees to access their corresponding territories as property of type EntitySet<T>.

  12. Entity Framework (3) • Create a method that places a new order in the Northwind database. The order should contain several order items. Use transaction to ensure the data consistency. • Create a stored procedures in the Northwind database for finding the total incomes for given supplier name and period (start date, end date). Implement a C# method that calls the stored procedure and returns the retuned record set.

More Related