In ActionResult "Details(int? id)" of a controller I have:
var TheUser = db.AspNetUsers.Where(u => u.Id == CurrentUser)
.Select(u => new
{
ID = u.Id,
Email = u.Email,
Username = u.UserName,
Surrname = u.Surname,
Name = u.Name,
Role = u.Role,
CreditBalance = u.CreditBalance
}).Single();
var TheJournal = db.CreditJournal.Where(tj => tj.CvID == id && tj.UseBy == CurrentUser)
.Select(tj => new
{
IdJournal = tj.IdJournal,
Operation = tj.Operation,
CvID = tj.CvID,
CreditConsumed = tj.CreditConsumed,
UseDate = tj.UseDate,
UseBy = tj.UseBy
});
var Counter = TheJournal.Count();
When I evaluate values in Debug Mode I have:
TheUser |>>> { ID = "56cc2430-4db5-4799-ad41-fa1d103d1967", Email = "sales@maps4u.ro", Username = "sales@maps4u.ro", Surrname = "Laurentiu", Name = "LAZAR", Role = 3, CreditBalance = 75 } <Anonymous Type>
TheJournal |>>> {System.Data.Entity.Infrastructure.DbQuery<<>f__AnonymousType9<int,string,int?,int?,System.DateTime?,string>>} System.Linq.IQueryable<<>f__AnonymousType9<int,string,int?,int?,System.DateTime?,string>> {System.Data.Entity.Infrastructure.DbQuery<<>f__AnonymousType9<int,string,int?,int?,System.DateTime?,string>>}
Counter |>>> The name 'Counter' does not exist in the current context
What can be wrong in simple code from above? (The equivalent SQL statement for TheJornal returns for the given criteria, at least 4 records). Somehow I think to declare the variables outside the condition, but what type have to be? (Anyway the first, TheUser is just ok, the issue start with second, TheJournal )
Aucun commentaire:
Enregistrer un commentaire