Skip to content

Commit 0506d0c

Browse files
authored
Merge pull request #2 from VenkateshwaranSaravanakumar/master
Modified sample and updated ReadMe file with additional details.
2 parents 02ca2e4 + 28393c5 commit 0506d0c

10 files changed

+33
-16
lines changed

AppData/AppointmentDataDB.mdf

-8 MB
Binary file not shown.

AppData/AppointmentDataDB_log.ldf

-8 MB
Binary file not shown.

Data/AppointmentDataContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
1515
RecordID = 1,
1616
Id = 1,
1717
Subject = "Meeting",
18-
StartTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 10, 0, 0),
19-
EndTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 12, 0, 0),
18+
StartTime = new DateTime(2023, 6, 5, 9, 0, 0),
19+
EndTime = new DateTime(2023, 6, 5, 10, 30, 0),
2020
Location = "Tamilnadu"
2121
}
2222
);

Migrations/20230525030615_SqlServerDataBinding.Data.AppointmentDataContext.Designer.cs renamed to Migrations/20230625145343_SqlServerDataBinding.Data.AppointmentDataContext.Designer.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Migrations/20230525030615_SqlServerDataBinding.Data.AppointmentDataContext.cs renamed to Migrations/20230625145343_SqlServerDataBinding.Data.AppointmentDataContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
4545
migrationBuilder.InsertData(
4646
table: "AppointmentDatas",
4747
columns: new[] { "RecordID", "CategoryColor", "CssClass", "Description", "EndTime", "EndTimezone", "EventCategory", "EventType", "Id", "IsAllDay", "IsBlock", "IsReadOnly", "Location", "OwnerId", "OwnerType", "RecurrenceException", "RecurrenceID", "RecurrenceRule", "StartTime", "StartTimezone", "Subject", "UserID" },
48-
values: new object[] { 1, null, null, null, new DateTime(2023, 5, 25, 12, 0, 0, 0, DateTimeKind.Unspecified), null, null, null, 1, false, null, null, "Tamilnadu", null, null, null, null, null, new DateTime(2023, 5, 25, 10, 0, 0, 0, DateTimeKind.Unspecified), null, "Meeting", null });
48+
values: new object[] { 1, null, null, null, new DateTime(2023, 6, 5, 10, 30, 0, 0, DateTimeKind.Unspecified), null, null, null, 1, false, null, null, "Tamilnadu", null, null, null, null, null, new DateTime(2023, 6, 5, 9, 0, 0, 0, DateTimeKind.Unspecified), null, "Meeting", null });
4949
}
5050

5151
protected override void Down(MigrationBuilder migrationBuilder)

Migrations/AppointmentDataContextModelSnapshot.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
101101
new
102102
{
103103
RecordID = 1,
104-
EndTime = new DateTime(2023, 5, 25, 12, 0, 0, 0, DateTimeKind.Unspecified),
104+
EndTime = new DateTime(2023, 6, 5, 10, 30, 0, 0, DateTimeKind.Unspecified),
105105
Id = 1,
106106
IsAllDay = false,
107107
Location = "Tamilnadu",
108-
StartTime = new DateTime(2023, 5, 25, 10, 0, 0, 0, DateTimeKind.Unspecified),
108+
StartTime = new DateTime(2023, 6, 5, 9, 0, 0, 0, DateTimeKind.Unspecified),
109109
Subject = "Meeting"
110110
});
111111
});

Pages/CustomAdaptorComponent.razor

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@using Microsoft.AspNetCore.Hosting;
88
@using System.Text.Json.Serialization;
99
@using SqlServerDataBinding.Data;
10-
@inject IHostingEnvironment _env
10+
@inject IConfiguration Configuration
1111

1212
@inherits DataAdaptor<AppointmentData>
1313

@@ -20,6 +20,8 @@
2020
[JsonIgnore]
2121
public RenderFragment ChildContent { get; set; }
2222

23+
public List<AppointmentData> Appointment { get; set; }
24+
2325
public static DataSet CreateCommand(string queryString, string connectionString)
2426
{
2527
using (SqlConnection connection = new SqlConnection(connectionString))
@@ -50,9 +52,7 @@
5052
// DataManagerRequest defines the members of the query
5153
public override object Read(DataManagerRequest DataManagerReq, string Key = null)
5254
{
53-
string AppData = _env.ContentRootPath;
54-
string DatabasePath = Path.Combine(AppData, "App_Data\\AppointmentDataDB.mdf");
55-
var connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=" + Directory.GetCurrentDirectory() + "\\AppData\\AppointmentDataDB.mdf;Integrated Security=True";
55+
string connectionString = Configuration.GetConnectionString("AppointmentDataDB");
5656
string QueryStr = "SELECT * FROM dbo.AppointmentDatas";
5757
DataSet Data = CreateCommand(QueryStr, connectionString);
5858
Appointment = Data.Tables[0].AsEnumerable().Select(r => new AppointmentData

Pages/Index.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,5 @@
2121
</SfSchedule>
2222

2323
@code {
24-
DateTime SelectedDate { get; set; } = new DateTime(2023, 5, 10);
25-
public static List<AppointmentData>? Appointment { get; set; }
24+
DateTime SelectedDate { get; set; } = new DateTime(2023, 6, 10);
2625
}

Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
using Syncfusion.Blazor;
66

77
var builder = WebApplication.CreateBuilder(args);
8-
var connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=" + Directory.GetCurrentDirectory() + "\\AppData\\AppointmentDataDB.mdf;Integrated Security=True";
8+
9+
var connectionString = builder.Configuration.GetConnectionString("AppointmentDataDB");
910
builder.Services.AddDbContext<AppointmentDataContext>(opts => opts.UseSqlServer(connectionString));
1011

1112
// Add services to the container.
@@ -14,6 +15,7 @@
1415
builder.Services.AddSingleton<WeatherForecastService>();
1516
builder.Services.AddSyncfusionBlazor();
1617

18+
1719
var app = builder.Build();
1820

1921
// Configure the HTTP request pipeline.

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
# blazor-scheduler-sql-server-databinding
1+
# Blazor-Scheduler-SQL-Server-Databinding
2+
3+
A quick start project that shows how to consume data from SQL Server using Microsoft SqlClient and bound it to Blazor Scheduler.
4+
5+
Documentation : https://blazor.syncfusion.com/documentation/scheduler/data-binding#sql-server-data-bindingsql-client
6+
7+
## Prerequisites
8+
9+
Make sure that you have the latest versions of 'Visual Studio 2022' in your machine before starting to work on this project. Ensure that you are having SQL Server Data Tools within Visual Studio 2022.
10+
11+
# How to run this application?
12+
13+
* To run this application, you need to first clone the <code>Blazor-Scheduler-SQL-Server-Databinding</code> repository and then open it in Visual Studio 2022.
14+
* Using the Migrations create the database by running the following command in the Package Manager console:
15+
> PM> update-database
16+
* Migrations automate the creation of database based on our Model. The EF Core packages required for migration will be added with .NET Core project setup.
17+
* Now, simply build and run your project to view the output.

0 commit comments

Comments
 (0)