Subscribe to Subscribers
Talk to Webmaster Tony John


Forums » .NET » LINQ »

The type not mapped as a table


Posted Date: 12 Jul 2012      Posted By:: Pughaz     Member Level: Silver    Member Rank: 1991     Points: 5   Responses: 1



hi friend,

this is my code

string cnstr = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
cn = new SqlConnection(cnstr);

dc = new DataContext(cn);

Table<aprole> dt1 = dc.GetTable<aprole>();//Error The type 'aprole' is not mapped as a Table.

var role = from c in dt1 where c.rolename == "Reviewer" select c;

foreach (var dtvalue in role)
{
Response.Write("table" + dtvalue);
}

aprole is a class name ..

everything has fine, where i want to give the table name (in the database i have table name aprole)

i have to fetch data from that table only..

thanx advance






Responses

#680078    Author: Kapil      Member Level: Gold      Member Rank: 51     Date: 12/Jul/2012   Rating: 2 out of 52 out of 5     Points: 2

Hi,

I will suggest to use LINQ-To-SQL Class (DataContext) for the database and it will map your table (just one) which ever you want.

Below is the article

http://www.codeproject.com/Articles/22000/LINQ-to-SQL

Happy Coding

"Please don't forget to Rate this answer if you found it usefull"

http://www.dotnetspider.com/mentors/86-kapil-deo.aspx
My Blog



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Where to start Linq?
Previous : Where and why we use LINQ
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2012 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.