The functionality is implemented in DocaLabs.Storage.

DbContext derived class can be generate the same way as for AzureTableContext IDbSet support for TableServiceContext and context code generation from interface

1. Define the entities
	public class Category
	{
		public Guid CategoryId { get; set; }
		public string Name { get; set; }
		
		public virtual ICollection<Product> Products { get; set; }
	}
	
	public class Product
	{
		public Guid ProductId { get; set; }
		public Guid CategoryId {get; set; }
		public string Name { get; set; }
		
		public virtual Category Category { get; set; }
	}

2. Define the context interface
	public interface IProductContext : IRelationalContextBase
	{
		IDbSet<Category> Categories { get; set; }
		IDbSet<Product> Products { get; set; }
	}

3. Then generate the context and use it. The type definition will be cached so the time penalty will be only the first time the context is generated
	var productContext = RelationalContextBase.CreateInstance<IProductContext>(nameOrConnectionString);

or equivalently
	var productContext = RepositoryGenerator.CreateInstance<TContextInterface>(typeof(RelationalContextBase), nameOrConnectionString);

Last edited May 15, 2011 at 11:24 AM by alexeikadyrov, version 4

Comments

No comments yet.