Skip to content

Commit

Permalink
Merge pull request #2 from VenkateshwaranSaravanakumar/master
Browse files Browse the repository at this point in the history
Modified sample and updated ReadMe file with additional details.
  • Loading branch information
maheshtps committed Jun 28, 2023
2 parents 02ca2e4 + 28393c5 commit 0506d0c
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 16 deletions.
Binary file removed AppData/AppointmentDataDB.mdf
Binary file not shown.
Binary file removed AppData/AppointmentDataDB_log.ldf
Binary file not shown.
4 changes: 2 additions & 2 deletions Data/AppointmentDataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
RecordID = 1,
Id = 1,
Subject = "Meeting",
StartTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 10, 0, 0),
EndTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 12, 0, 0),
StartTime = new DateTime(2023, 6, 5, 9, 0, 0),
EndTime = new DateTime(2023, 6, 5, 10, 30, 0),
Location = "Tamilnadu"
}
);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
migrationBuilder.InsertData(
table: "AppointmentDatas",
columns: new[] { "RecordID", "CategoryColor", "CssClass", "Description", "EndTime", "EndTimezone", "EventCategory", "EventType", "Id", "IsAllDay", "IsBlock", "IsReadOnly", "Location", "OwnerId", "OwnerType", "RecurrenceException", "RecurrenceID", "RecurrenceRule", "StartTime", "StartTimezone", "Subject", "UserID" },
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 });
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 });
}

protected override void Down(MigrationBuilder migrationBuilder)
Expand Down
4 changes: 2 additions & 2 deletions Migrations/AppointmentDataContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
new
{
RecordID = 1,
EndTime = new DateTime(2023, 5, 25, 12, 0, 0, 0, DateTimeKind.Unspecified),
EndTime = new DateTime(2023, 6, 5, 10, 30, 0, 0, DateTimeKind.Unspecified),
Id = 1,
IsAllDay = false,
Location = "Tamilnadu",
StartTime = new DateTime(2023, 5, 25, 10, 0, 0, 0, DateTimeKind.Unspecified),
StartTime = new DateTime(2023, 6, 5, 9, 0, 0, 0, DateTimeKind.Unspecified),
Subject = "Meeting"
});
});
Expand Down
8 changes: 4 additions & 4 deletions Pages/CustomAdaptorComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@using Microsoft.AspNetCore.Hosting;
@using System.Text.Json.Serialization;
@using SqlServerDataBinding.Data;
@inject IHostingEnvironment _env
@inject IConfiguration Configuration

@inherits DataAdaptor<AppointmentData>

Expand All @@ -20,6 +20,8 @@
[JsonIgnore]
public RenderFragment ChildContent { get; set; }

public List<AppointmentData> Appointment { get; set; }

public static DataSet CreateCommand(string queryString, string connectionString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
Expand Down Expand Up @@ -50,9 +52,7 @@
// DataManagerRequest defines the members of the query
public override object Read(DataManagerRequest DataManagerReq, string Key = null)
{
string AppData = _env.ContentRootPath;
string DatabasePath = Path.Combine(AppData, "App_Data\\AppointmentDataDB.mdf");
var connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=" + Directory.GetCurrentDirectory() + "\\AppData\\AppointmentDataDB.mdf;Integrated Security=True";
string connectionString = Configuration.GetConnectionString("AppointmentDataDB");
string QueryStr = "SELECT * FROM dbo.AppointmentDatas";
DataSet Data = CreateCommand(QueryStr, connectionString);
Appointment = Data.Tables[0].AsEnumerable().Select(r => new AppointmentData
Expand Down
3 changes: 1 addition & 2 deletions Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@
</SfSchedule>

@code {
DateTime SelectedDate { get; set; } = new DateTime(2023, 5, 10);
public static List<AppointmentData>? Appointment { get; set; }
DateTime SelectedDate { get; set; } = new DateTime(2023, 6, 10);
}
4 changes: 3 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
using Syncfusion.Blazor;

var builder = WebApplication.CreateBuilder(args);
var connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=" + Directory.GetCurrentDirectory() + "\\AppData\\AppointmentDataDB.mdf;Integrated Security=True";

var connectionString = builder.Configuration.GetConnectionString("AppointmentDataDB");
builder.Services.AddDbContext<AppointmentDataContext>(opts => opts.UseSqlServer(connectionString));

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


var app = builder.Build();

// Configure the HTTP request pipeline.
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# blazor-scheduler-sql-server-databinding
# Blazor-Scheduler-SQL-Server-Databinding

A quick start project that shows how to consume data from SQL Server using Microsoft SqlClient and bound it to Blazor Scheduler.

Documentation : https://blazor.syncfusion.com/documentation/scheduler/data-binding#sql-server-data-bindingsql-client

## Prerequisites

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.

# How to run this application?

* 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.
* Using the Migrations create the database by running the following command in the Package Manager console:
> PM> update-database
* 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.
* Now, simply build and run your project to view the output.

0 comments on commit 0506d0c

Please sign in to comment.