I have an existing SQL Server database where I store data from large log files (often 100 MB or more), one per database. After some analysis, the database is deleted again.
From the database, I created both the Entity Framework model construct and the DataSet model using Visual Studio designers. The DataSet is intended for bulk data import from SqlBulkCopyafter a rather complicated parsing process. All requests are then executed using the Entity Framework model, CreateQuerywhose method is opened through an interface similar to this.
public IQueryable<TTarget> GetResults<TTarget>() where TTarget : EntityObject, new()
{
return this.Context.CreateQuery<TTarget>(typeof(TTarget).Name);
}
Now, sometimes my files are very small, and in that case I would like to omit the import into the database, but just have a view in the data memory accessible as Entities. The idea is to create a DataSet, but instead of bulk import, directly pass it to an ObjectContext accessible through the interface.
It makes sense?
Now here's what I did for this conversion: I move all the tables to a DataSet, convert individual rows into entities of the appropriate type, and add them to an object instance of my typed Entity context class, for example
MyEntities context = new MyEntities();
MyDataSet.NavigationResultRow dataRow = ds.NavigationResult.First();
NavigationResult entity = new NavigationResult
{
Direction = dataRow.Direction,
NavigationResultID = dataRow.NavigationResultID
};
context.AddToNavigationResult(entity);
Very tedious work, since I will need to create a converter for each of my entity types and iterate over each table in the DataSet that I have. Beware if I ever change my database model ....
, , MyEntities, SQL Server. , . - .
? - , , ObjectContext DataSet?
P.S: , , .