I have a web page in which I am giving USER the options of writing notes. Now when ever the web page checks that a USER is:abc then it pulls up the note from the MEMO Table.
Here is my code in Page_Load():
using (EntityMemoDataContext em = new EntityMemoDataContext())
{
int getEntity = Int16.Parse(Session["EntityIdSelected"].ToString());
var showMemo = from r in em.EntityMemoVs_1s
where r.EntityID == getEntity
select r.Memo;
tbShowNote.Text = String.Join(@"<br />", showMemo);
}
tbShowNote is showing me value like this:
test<br />test1<br />test1<br />test4<br />test4
And I want it like this:
Test
Test1
Test2 …
tbShowNote is a TextBox!
You only asked for the first memo, so that’s what you got back. If you want it enumerated with each one on it’s own line in html, you could do this:
The key takeaway is if r.Memo is of type string, then the LINQ query you executed gave you back a
IQueryable<string>. It’s on you to decide if you want to flatten that list later.Edit: Equiso made a good observation in that you’re actually returning an
IQueryableof an anonymous type, notIQueryable<string>due to thenew { ... }syntax. I’d say combine his answer with mine and run with it: