Click here to Skip to main content
15,851,902 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
im refering: Microsoft.press.microsoft.ado.net.4.step.by.step.oct.2010
I was trying linq to sql, but i get this error:"The type 'ADODOTNET.Emp' is not mapped as a Table."
C#
public class SalesOrder : DataContext
{
        // ----- Constructor establishes database connection.
        public SalesOrder(string connectionString) : base(connectionString) { }
        // ----- Table definitions to link with database.
        public Table<Emp> Employee;

}


Emp table has 4 coloumns:
ID
fname
Lname
Salary

I was firing below linq query:

C#
using (SalesOrder context = new SalesOrder(linkToDB.ToString()))
            {
                var linqresult = from cu in context.Employee
                                 select new { CustomerID = cu.ID, CustomerName = cu.LNAME };
            }
Posted
Updated 19-Jul-12 4:01am
v2

1 solution

This[^] is the best thing to do when you need help with a specific error message.
 
Share this answer
 
Comments
Mohit Bhati 20-Jul-12 4:18am    
hi Christian,
what should i do to map "Emp" as a table in my code?
Christian Graus 20-Jul-12 17:48pm    
Is this Entity Framework ? If it's not, then I have no clue, with EF, if you're not just creating a model based on a DB so if the table is there, it gets imported, then you write a class for each table.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900