Be careful what you LINQ for: Mixing LINQ to SQL with LINQ to Entities

Wednesday, May 28, 2014

An exception I encountered today, led me to pay more attention about the differences between LINQ to SQL and LINQ to Entities. Here is what I learned; Imagine your in a school, and the students council has announced the winners in the school's yearly programming competition. We have a bunch of students, and the winners names. Let's get all the winning student, that's easy: using (var db = new School()) { //Create students list var students = new List<Student> { new Student { ID =...
no comments

SQL – Create and use a stored procedure with table as a parameter

Tuesday, April 29, 2014

Using SQL Server 2012 Assuming we have a sample "TestDB" with the following scheme: Create a type which will use for the input parameter: Create a new stored procedure Fill in the stored procedure name, the parameter name and the query Notice the CostumersIDs is the parameter name and CostumersIdsType is it's type which we created earlier. For simplicity, the query I used just returns the received input parameter. Test the stored procedure in sql server: What happened here is: - We created a temporary table of our declared type (CostumersIdsType), and inserted into it a few value. - Called our stored procedure with the temporary table as a...
tags: , ,
no comments