JohnWayne
JohnWayne

Reputation: 115

Adding data to database using asp.net 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 EventController code:

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

Upvotes: 0

Views: 672

Answers (1)

CoOl
CoOl

Reputation: 2797

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.

Upvotes: 1

Related Questions