8029 3
Getting error "Sequence contains no elements"

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

...

Type
Question
8008 1
Serialization & Deserialization in C# With Console application example
In this article, I have explained the concept of Serialization & Deserialization Class object in C# with an working console application example.
Type
Article
7998 1
How do I create object for IQueryable in C#?

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

...
Type
Question
7810 0
C# Regex Examples and Basics
In this article, we have provided examples of C# Regex (Regular Expression) with sample cases and testing them in C# Console application with explanation of what is Regular Expression in C#.
Type
Article
7585 3
How to convert JSON String into C# class object

I am trying to convert JSON object into C# class object, Using a really simple test case:

...
Type
Question


7436 1
How can I run raw SQL query in C#? ( With and Without ADO.NET)

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?

...
Type
Question
7313 1
How to validate TinyMCE textarea in ASP.NET MVC?

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

...
Type
Question
7243 2
JSON.NET Error Self referencing loop detected for type

I am trying to convert List into JSON format using the code below

...
Type
Question
6824 1
Convert PDF to Image in C# (Console Application Example)
In this article, I have provided sample code to convert PDF file to image using C#, we will be using PDFium library for this.
Type
Article
6758 2
How to rename a file and directory in C#?

I am working with files and directory in C#, so I would like to know how can I rename a file and directory in C#? I would like to rename file first and then in some cases would have to rename directory also.

I see there is File.Move Method, but is there any other method or way to rename a file and what about Directory, how to rename directory?

...
Type
Question

Page 10 of 24