Johnane Umslana Johnane Umslana - 7 months ago 53
ASP.NET (C#) Question

Adding data to database using mvc

I'm trying to add data to the Event table in SQL Server.
This is the table details:

CREATE TABLE [dbo].[Event]
[EventID] [int] IDENTITY(1001,1) NOT NULL,
[EventName] [nvarchar](50) NOT NULL,
[EventDesc] [nvarchar](50) NOT NULL,
[EventLogo] [image] NULL,
[EventLocation] [decimal](9, 6) NULL,
[EventDate] [nvarchar](20) NOT NULL,
[EventStartTime] [nvarchar](7) NOT NULL,
[EventEndTime] [nvarchar](7) NOT NULL,
[NumOfAttendees] [nvarchar](7) NULL,
[EventStatus] [nvarchar](5) NOT NULL,
[UserID] [int] NULL,
[CategoryID] [int] NULL,
[RatingID] [int] NULL,
[FeedbackID] [int] NULL

This is where I receive the error:

Keyword, identifier or string expected after verbatim specifier @

This is the

public ActionResult Index()
var events = db.Events.Include(@ => @.Category).Include(@ => @.Feedback).Include(@ => @.Rating).Include(@ => @.User);
return View(events.ToList());


Change it to -

db.Events.Include(c => c.Category).Include(f => f.Feedback).Include(r => r.Rating).Include(u => u.User);

@ is a keyword which is used for verbatim literals.