P
Priya Bange
Guest
Hi Experts,
Am using a library to parse SQL Server generated files & also a newbie with C# . So am able to read the file using the library and load into a data table now the challenge what am facing as it appears as an Asychronous operations it may be creating multiple instances of Data Table for each and every row..
What am looking for
Entire content processed by XeExtract available for further data manipulations available in a single DT once the entire file is read"processed"..
Kindly help
Code sample below
USING Microsoft.SqlServer.XEvent.XELite;
private static DataTable CreateDataTable()
{
var dt = new DataTable();
dt.Columns.Add("Event_Name", typeof(string));
dt.Columns.Add("object_name", typeof(string));
dt.Columns.Add("object_id", typeof(Int32));
return dt;
}
public static void XeFile(String InputFilePath)
{
var xeStream = new XEFileEventStreamer(InputFilePath);
xeStream.ReadEventStream(
xevent =>
{
XEextract(xevent);
return Task.CompletedTask;
},
CancellationToken.None).Wait();
}
private static void XEextract(IXEvent xe)
{
var dt = CreateDataTable();
var row = dt.NewRow();
row["Event_Name"] = xe.Name;
xe.Fields.TryGetValue("object_id", out object object_id);
row["object_id"] = object_id == null ? 0 : object_id;
xe.Fields.TryGetValue("object_name", out object object_name);
row["object_name"] = object_name == null ? string.Empty : object_name;
}
Thanks
Priya
Continue reading...
Am using a library to parse SQL Server generated files & also a newbie with C# . So am able to read the file using the library and load into a data table now the challenge what am facing as it appears as an Asychronous operations it may be creating multiple instances of Data Table for each and every row..
What am looking for
Entire content processed by XeExtract available for further data manipulations available in a single DT once the entire file is read"processed"..
Kindly help
Code sample below
USING Microsoft.SqlServer.XEvent.XELite;
private static DataTable CreateDataTable()
{
var dt = new DataTable();
dt.Columns.Add("Event_Name", typeof(string));
dt.Columns.Add("object_name", typeof(string));
dt.Columns.Add("object_id", typeof(Int32));
return dt;
}
public static void XeFile(String InputFilePath)
{
var xeStream = new XEFileEventStreamer(InputFilePath);
xeStream.ReadEventStream(
xevent =>
{
XEextract(xevent);
return Task.CompletedTask;
},
CancellationToken.None).Wait();
}
private static void XEextract(IXEvent xe)
{
var dt = CreateDataTable();
var row = dt.NewRow();
row["Event_Name"] = xe.Name;
xe.Fields.TryGetValue("object_id", out object object_id);
row["object_id"] = object_id == null ? 0 : object_id;
xe.Fields.TryGetValue("object_name", out object object_name);
row["object_name"] = object_name == null ? string.Empty : object_name;
}
Thanks
Priya
Continue reading...