0

I have a simple query that I'm trying to execute:

sql = "SELECT DailyGamingID, GamingDate, LocationID FROM tblDailyGaming WHERE GamingDate >= '1/1/23' AND LocationID = 1";
List<TestData> testList = context.Database.SqlQuery<TestData> (sql).ToList ();

The query returns 10 rows.

I also have the following class:

public class TestData
{
    public int DailyGamingID;
    public DateTime GamingDate;
    public int LocationID;
}

testList will have the correct number of elements (10) in the list but none of the values of TestData have been set. They are all default values. Help please!

0

1 Answer 1

1

You need to make those properties - not fields - in your class:

public class TestData
{
    public int DailyGamingID { get; set; };
    public DateTime GamingDate { get; set; };
    public int LocationID { get; set; };
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.