Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# entity framework using LINQ [closed]

I have a job interview tomorrow and they stated that i have an exam about "C# development using entity framework and LINQ".

For me, entity framework and LINQ are two new approaches. I already know to build C# application where i'd connect the app to a SQLServer database, using the normal connection strings and SQL syntax.

When researching about Entity framework, as a start i learned that i can use the SQLServer object explorer, and create a local database easily from visual studio, then add an OLE.net entity model and perform changes easily. As an example, you can see the following code below used to insert a student in a student list.

  using (SchoolEntities1 context = new SchoolEntities1())
            {
                StudentList sl = new StudentList
                {
                    Name = tb_Name.Text,
                    Gender = cb_Gender.Text,
                    Grade = Convert.ToInt32(tb_Grade.Text)
                };
                context.StudentLists.Add(sl);
                context.SaveChanges();

            }

Is this the basic function of entity framework? Should i study anything else that might be useful (other than database manipulation INSERT/UPDATE/DELETE/SELECT)?

Additionally for the LINQ, when researching about it, i see different types of coding as an example, is the definition of student list in the code above a LINQ function? Do i have to use lambda expressions in my codes?

Any links that can help me in this small time frame would be appreciated.

Thanks.

like image 555
Nassif Avatar asked Sep 25 '16 08:09

Nassif


2 Answers

There are 3 kinds of EF approaches.Those are:

  1. Model First
  2. Database First
  3. Code First

Here you can find out basics of EF: Entity Framework Basics

There are 2 types of query methods.Those are:

1. Query based

e.g : Projection

IQueryable<Product> productsQuery = from product in context.Products
                                        select product;

2. Method based

e.g : Projection

 var query = context.Products
        .Select(product => new
        {
            ProductId = product.ProductID,
            ProductName = product.Name
        });

Here you can see this: Queries in LINQ to Entities

You can find out more at Entity Framework Interview Questions and Answers

Good Luck to you ! :)

like image 183
Sampath Avatar answered Oct 05 '22 23:10

Sampath


For MVC as far as I know a basic crud Operation will be a good as a starter .That means Insert ,Update,Delete ,Details,Cascading dropdown list.But Besides you should gain knowledge about MVC routing clearly.

Currently you don't have any lambda expressions in your code.Basic Linq like list,count,joining etc you can learn in short time .

here is the data first approach data first

code first approach code first

linq basic interview questions linq interview questions

And yes get some knowledge about relationship process.

like image 33
Asifuzzaman Redoy Avatar answered Oct 05 '22 23:10

Asifuzzaman Redoy