This is my code for grab data from table to List using stored procedure. My question is how I will grab data to List without using stored procedure ?
using ( CWPRTestEntities ctx=new CWPRTestEntities())
{
var qry = from okc_SelectCyclicalWorkOrdersGenerated_Result p in ctx.okc_SelectCyclicalWorkOrdersGenerated() select p;
List
foreach (okc_SelectCyclicalWorkOrdersGenerated_Result myworkerder in myworkorders)
{
//TO Do
}

Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 2, 2013, 7:52 PM EDT
for example, you have table in database called "Mytest"
so you may write following query to find out result
using ( CWPRTestEntities ctx=new CWPRTestEntities())
{
var qry = ctx.MyTest.Where(i=>i.Id ==2);
}
or
using ( CWPRTestEntities ctx=new CWPRTestEntities())
{
var qry = from t in ctx.MyTest
where t.Id ==2
select t;
}
hope this will help you.
Abey Varghese18 reputationPosted Apr 3, 2013, 4:41 AM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 3, 2013, 4:54 AM EDT
hi,
Var keyword is an implicit way of defining DataTypes. Implicit means indirect way of defining variable types..
at the time of Compilation this variable is automatically converted in to desired type. inyour case it converted to IEnumerable
you may use your costom class instead of table class.
hope this will help you.
Abey Varghese18 reputationPosted Apr 3, 2013, 6:27 AM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 3, 2013, 8:31 PM EDT
hi,
Please refer below link, it help you to understand entity framework
http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx
http://msdn.microsoft.com/en-us/library/gg696167%28VS.103%29.aspx