2013-10-30 12 views

답변

0

당신은 텍스트 상자에 개체의 속성을 지정 욕망과보다 엔티티 (= 표)를로드 할 수 있습니다.

뭔가 같은 :

using (var myContext = new EntityContext()) 
{ 
myContext.TableName.Load(); //this will load all rows from the table 

var list = myContext.TableName.Local; //.Local is a list of the entities which gets populated when you cann the Load() method 

//now you can either enumarte your list like so 
foreach (TableName item in list) 
{ 
string sName = item.PropertyName; //PropertyName is the property you want to display, this would be like using not an index in myReader.GetString(1) but the columnname myReader.GetString("ColumnName") 
txtName.Text = sName; 
} 

//or if you want to get a certain item out of your list you can use LINQ/MethodChains 
//MethodChain 
var item = list.First(x => x.PropertyName == "HelloWorld!"); 
string sName = item.PropertyName; 
txtName.Text = sName; 

//LINQ 
var item = (from x in list 
      where x.PropertyName == "HelloWorld!" 
      select x).First(); 

string sName = item.PropertyName; 
txtName.Text = sName; 

//the methodchain and linq is a "new" technology that simplifies this code (which does the same) 
TableName item = null; 
foreach (TableName tempItem in list) 
{ 
    if (tempItem.PropertyName == "HelloWorld!") 
    { 
     item = tempItem; 
     break; 
    } 
} 

string sName = item.PropertyName; 
txtName.Text = sName; 

}

관련 문제