Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get back result from a session
    text
    copied!<p>Work on entity frame work vs2010</p> <p>After execute my linq query get a list of records ,want to put this record in session .Now from session Want to get back my record list ,what to do how to get back record from a session</p> <p>Linq query</p> <pre><code> public IEnumerable GetSearchUserGroupPermissionData(int userID = 0) { var query = from p in this.Context.CmnPermissionGroupUsers join q in this.Context.CmnPermissionGroups on p.PermissionGroupID equals q.PermissionGroupID join r in this.Context.CmnPermissionGroupDocs on p.PermissionGroupID equals r.PermissionGroupID join s in this.Context.CmnUserInfoes on p.UserID equals s.UserID join t in this.Context.CmnDocLists on r.DocListID equals t.DocListID //join u in this.Context.CmnModuleFormCompanies on t.ModuleID equals u.ModuleID //join v in this.Context.CmnModuleLists on u.ModuleID equals v.ModuleID //join w in this.Context.CmnFormLists on u.FormID equals w.FormID where p.IsDeleted == false select new { RecordID = p.PermissionGroupUserRecordID, s.UserID, s.UserFirstName, q.PermissionGroupName, p.EffectiveDate, p.StatusID, t.DocListID, t.DocName, t.ModuleID, // v.ModuleName, // u.FormID, // t.FormName, // w.FormName, t.ParentID, t.Sequence, t.IsApprovalRequired, t.CompanyCategoryID, t.DocTypeID //p.CreateBy, //p.CreateOn, //p.CreatePc, //p.UpdateBy, //p.UpdateOn, //p.UpdatePc, //p.IsDeleted, //p.DeleteBy, //p.DeleteOn, //p.DeletePc, //p.Transfer }; return query.WhereIf(userID != 0, w =&gt; w.UserID == userID).ToList(); } </code></pre> <p>Put result in session</p> <pre><code>Session["UserPermission"] = new PermissionGroupUserController().GetSearchUserGroupPermissionData(objEntity.UserID); </code></pre> <p>Now ,want to get back the record set from session.bellow foreach syntax area as a item contain each row all properties and values but can not assign in a variable just like bellow ,why can not assign an AnonymousType variable value to a variable. <img src="https://i.stack.imgur.com/bSUgi.png" alt="enter image description here"> var o = Session["UserPermission"] as IEnumerable; //use casting foreach (var area in o) { //int a = area.UserID; }</p> <p>Note:sabove syntax how me error </p> <blockquote> <p>message:foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator'</p> </blockquote> <p>If have any query please ask.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload