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 TrivediPosted Apr 4, 2013, 12:31 AM
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
Abey VarghesePosted Apr 3, 2013, 10:27 AM
Jignesh TrivediPosted Apr 3, 2013, 8:54 AM
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 VarghesePosted Apr 3, 2013, 8:41 AM
Jignesh TrivediPosted Apr 2, 2013, 11:52 PM
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.