Initialize Calendars

I am new to Visual Studio.  I am trying to initialize the Calendars using the following.

using Dapper;

using System.Data;

using System.Collections.Generic;

using System.Linq;

using Microsoft.Data.SqlClient;

using System.Threading.Tasks;


namespace SamsSchedule.Data

{

    public class CalendarService : ICalendarService

    {

        private readonly SamsConfiguration _configuration;


        public CalendarService(SamsConfiguration samsConfiguration)

        {

            _configuration = samsConfiguration;

        }


        public async Task<List<CalendarData>> GetCalendarAll()

        {

            using (var conn = new SqlConnection(_configuration.Value))

            {

                const string sql = @"SELECT * FROM CalendarData";


                List<CalendarData> crew = (List<CalendarData>)await conn.QueryAsync<CalendarData>(sql);

                return crew.ToList();

            }

        }

    }

}


// Calendars.AddRange has an error

public List<CalendarData> Calendars { get; set; } = new List<CalendarData>

    {

        Calendars.AddRange(CalendarService.GetCalendarAll())

    };



1 Reply

VD Vinitha Devi Murugan Syncfusion Team November 22, 2021 12:32 PM UTC

Hi Martin, 
 
Greetings from Syncfusion Support. 
 
We have validated your reported query “Calendars.AddRange has an error” at our end. We suggest you to refer below common link to resolve your reported problem. 
 
 
Also, we suggest you to refer below UG documents for more information. 
 
 
Kindly try with the above link and get back to us if you need any further assistance. 
 
Regards, 
Vinitha 


Loader.
Up arrow icon