In .NET framework, we can load the .sdf file using System.Data.Linq.DataContext. But this is not available in .NET Core.
How can we use .sdf files in .NET Core?
````
public partial class Northwind : System.Data.Linq.DataContext
{
private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
....
public Northwind(string connection) :
base(connection, mappingSource)
{
OnCreated();
}
.....
public System.Data.Linq.Table
{
get
{
return this.GetTable
}
}
public System.Data.Linq.Table
{
get
{
return this.GetTable
}
}
public System.Data.Linq.Table
{
get
{
return this.GetTable
}
}
public System.Data.Linq.Table
{
get
{
return this.GetTable
}
}
public System.Data.Linq.Table
{
get
{
return this.GetTable
}
}
public System.Data.Linq.Table
{
get
{
return this.GetTable
}
}
public System.Data.Linq.Table
{
get
{
return this.GetTable
}
}
public System.Data.Linq.Table
{
get
{
return this.GetTable
}
}
}
// Getting Data
private void PopulateData()
{
{
Random r = new Random();
Northwind north = new Northwind(string.Format(@"Data Source= {0}", FindFile("Northwind.sdf")));
foreach (OrderDetails orderDet in north.OrderDetails.Take(50))
{
OrderInfo orderInfo = new OrderInfo();
orderInfo.OrderID = orderDet.OrderID;
orderInfo.CustomerID = orderDet.Orders.CustomerID;
orderInfo.ProductName = orderDet.Products.ProductName;
orderInfo.UnitPrice = (double)orderDet.UnitPrice;
orderInfo.OrderDate = (DateTime)orderDet.Orders.OrderDate;
orderInfo.DeliveryDelay = (DateTime)orderDet.Orders.ShippedDate - orderInfo.OrderDate;
orderInfo.Quantity = orderDet.Quantity;
orderInfo.ContactNumber = r.Next(999111234, 999111239).ToString();
orderInfo.ShipAddress = orderDet.Orders.ShipAddress;
_orderList.Add(orderInfo);
}
}
}
Any update regarding this?
Any update regarding this??
Any Update?
CC. @danmosemsft, do you know who owns this?
If I understand right the question is really how to open an.sdf file (SQL Compact) file from within a.NET Core app. Not specific to Linq to SQL. That would be a question for the Data team. @cheenamalhotra ?
/cc @ErikEJ
AFAIK there's no support for SQL Server CE (officially deprecated in 2013) on .NET Core.
(FYI @danmosemsft @tannergooding I get notified of any issue labelled System.Data)
Yes, you can use SQL Server Compact from .NET Core, and pass the SqlCeConnection object to your LINQ to SQL DataContext constructor https://github.com/dotnet/corefx/issues/33897#issuecomment-536269132 (Not the string based constructor)
Am going to go ahead and close this as there's a solution, and nothing is actionable from our end.
@roji How do you configure a notification on Github label(s)?
We have an internal bot doing this, I'm not aware of a public solution... But I heard github are working on this feature!
Lucky you!
Most helpful comment
Yes, you can use SQL Server Compact from .NET Core, and pass the SqlCeConnection object to your LINQ to SQL DataContext constructor https://github.com/dotnet/corefx/issues/33897#issuecomment-536269132 (Not the string based constructor)