c# - How to cast anonymous type to specified cast to get all its properties -


This code is returning me a list that I am trying to pass some other function.

  _ucItem.lblItemName.Text = itemRow.Field & lt; String & gt; ("ITEM_NAME") ToString (); _ucItem.pbxItemImg.Image = itemRow.Field & lt; String & gt; ("IMAGE"). ToString (); _ucItem.lblItemName.Text = itemRow.Field & lt; String & gt; ("FK_ITEM_ID"). ToString ();  

I want to change this set of lines with the result set here that I am trying to pass, do I have to declare a class to do this or the structure of a class There is no way to do the same thing without defining

  private zeros some functions () {var distinctItems = itemListToCreate. = & Gt; New {FK_ITEM_ID = dr.Field & lt; Long & gt; ("FK_ITEM_ID"}}). Specific () .joint (_SelectProgram.FilteredItemDescription, external = & outer.FK_ITEM_ID, internal = & gt; inner.Field & lt; tall & gt; ("FK_ITEM_ID"), (internal, external) => new {internal .FK_ITEM_ID}, item name = external.field & lt; string & gt; ("ITEM_NAME"), itemImage = outer.field & lt; byte [] & gt; ("IMAGE")}); CreateItemsDynamically (distinctItems.ToList ()); } Private Zero CreateItemsDynamically & lt; T & gt; (List & lt; T & gt; itemListToCreate) {itemListToCreate.ForEach (itemRow = & gt; {ucItem _ucItem = new ucItem (); // this usercontrol _ucItem.lblItemName.Text = itemRow.Field & lt; string & gt; ("ITEM_NAME"); ToString (); _ucItem.pbxItemImg.Image = itemRow.Field & lt; string & gt; ("IMAGE"). ToString (); _ucItem.lblItemName.Text = itemRow.Field & lt; string & gt; ( "FK_ITEM_ID") .ToString (); _ucItem.TodayButton_OnClick + = new eventhandler (_ucItem_TodayButton_OnClick); _ucItem.MultiDateButton_OnClick + = new eventhandler (_ucItem_MultiDateButton_OnClick); pnlItemCollection.Controls.Add (_ucItem); _SelectProgram.ItemCollectionList .Add (_ucItem);}); }  

A type is either explicitly named or anonymous if you first type - declare the structure or class.


Comments