Link to home
Start Free TrialLog in
Avatar of RBS
RBS

asked on

Converting SQL Procedure to LINQ

Hi:

I'm a bit panicked trying to do a major change from an internet cafe on my vacation - so pls excuse simplicity of request -

Need to transfer the following sql query to Linq:

SELECT   Id, 
	CASE
		WHEN CourseInstance>1 THEN 
				Name + 
				+ ' - '  + 
				CAST(Year(RegisterDate) AS varchar(4))+ '-' + 
				CAST(Month(RegisterDate) AS varchar(2)) 
			ELSE Name 
	END AS Course,
FROM    Enrollments

Open in new window


I have created a repository and am making modifications to it in following:

 public IEnumerable<Enrollment> GetEnrollmentsByUserName(string userName)
        {
            return DbSet.Where(e => e.UserName == userName); ????????????????????

        }

Open in new window


Any help in translating the query from the top to the area with the question marks below   greatly appreciated!

RBS
Frozen Brain
ASKER CERTIFIED SOLUTION
Avatar of Argenti
Argenti
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RBS
RBS

ASKER

Excellent - thanks!

Roger