Hello, I am using the below code to fetch some data from database and getting the error "Sequence contains no elements"
public static IEnumerable<CompanyLicenseKey> GetCompanyLicenseKey()
{
OPEntities onepassDB = new OPEntities();
//Let's get the onepass User model first
var user = onepassDB.UserAccounts.Where(x => x.Email == OnePassUserAccountEmail).First(); //error in this line
var userLicenseList = from c in user.CompanyProfiles
join l in onepassDB.CompanyLicenseKeys.Where(x => x.IsDisabled == false)
.Select(x => new { x.CRMID, x.LicenseKey, x.FriendlyName, x.ProductName })
on new { c.CRMID } equals new { l.CRMID }
select new Models.OnePass.CompanyLicenseKey { LicenseKey = l.LicenseKey, FriendlyName = l.FriendlyName, ProductName = l.ProductName };
if (ProductName == "")
return userLicenseList.ToList().OrderBy(x => x.FriendlyName);
else
return userLicenseList.Where(x => x.ProductName == ProductName).ToList().OrderBy(x => x.FriendlyName);
}
Error image
...
I am trying to create and Instantiate IQueryable<T> object in my C# MVC project, but I am not able to create it, I would like to use it instead of List<T> = new List<T>
, so how can I do it? I am trying this
I am trying to convert JSON object into C# class object, Using a really simple test case:
...I am trying to optimise my query to get data from database, so I would to know how can I directly run a sql query in my C#.
Currently I am using Entity framework with EDMX, so to improve query time, I would like to know how can I run direct sql query?
...How can i validate TinyMCE using asp.net MVC and razor? Currently, i was trying to validate it using Model validations but it is not working and not showing any errors even when TinyMCE textarea is blank, so how can i validate it? here is my javascript code
...I am trying to convert List into JSON format using the code below
...Hi, i would like to get page number of Current page in jQuery or in HTML of the Asp.net MVC PagedList.IPagedList.
...