mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
96 lines
3.7 KiB
Plaintext
96 lines
3.7 KiB
Plaintext
<%@ Template Language="C#" TargetLanguage="C#" Debug="True" Encoding="UTF-8" %>
|
|
|
|
<%@ Assembly Src="Model.cs" %>
|
|
<%@ Assembly Src="Extensions.cs" %>
|
|
|
|
<%@ Import Namespace="System.Collections.Generic" %>
|
|
<%@ Import Namespace="System.Linq" %>
|
|
<%@ Import Namespace="System.Text" %>
|
|
<%@ Import Namespace="System.Text.RegularExpressions" %>
|
|
|
|
<%@ Import Namespace="SchemaMapper" %>
|
|
|
|
<%@ Property Name="EntityContext" Type="SchemaMapper.EntityContext" %>
|
|
|
|
<%@ Property Name="ContextNamespace" Type="System.String" %>
|
|
<%@ Property Name="EntityNamespace" Type="System.String" %>
|
|
<%@ Property Name="MappingNamespace" Type="System.String" %>
|
|
<%@ Property Name="InterfaceMode" Type="Boolean" Default="False" Optional="True" %>
|
|
|
|
//------------------------------------------------------------------------------
|
|
// <autogenerated>
|
|
// This code was generated by a CodeSmith Template.
|
|
//
|
|
// DO NOT MODIFY contents of this file. Changes to this
|
|
// file will be lost if the code is regenerated.
|
|
// </autogenerated>
|
|
//------------------------------------------------------------------------------
|
|
using System;
|
|
using System.Data.Entity;
|
|
using System.Collections.Generic;
|
|
using <%= EntityNamespace %>;
|
|
using <%= MappingNamespace %>;
|
|
|
|
namespace <%= ContextNamespace %>
|
|
{
|
|
<% if (InterfaceMode) { %>
|
|
public interface IDbContext : IDisposable
|
|
{
|
|
System.Data.Entity.Database Database { get; }
|
|
System.Data.Entity.Infrastructure.DbChangeTracker ChangeTracker { get; }
|
|
System.Data.Entity.Infrastructure.DbContextConfiguration Configuration { get; }
|
|
|
|
System.Data.Entity.Infrastructure.DbEntityEntry Entry(object entity);
|
|
System.Data.Entity.Infrastructure.DbEntityEntry<TEntity> Entry<TEntity>(TEntity entity) where TEntity : class;
|
|
|
|
IEnumerable<System.Data.Entity.Validation.DbEntityValidationResult> GetValidationErrors();
|
|
|
|
System.Data.Entity.DbSet Set(Type entityType);
|
|
System.Data.Entity.IDbSet<TEntity> Set<TEntity>() where TEntity : class;
|
|
|
|
int SaveChanges();
|
|
}
|
|
|
|
public partial interface I<%= EntityContext.ClassName.ToSafeName() %> : IDbContext
|
|
{
|
|
<% foreach(var p in EntityContext.Entities) { %>
|
|
System.Data.Entity.IDbSet<<%= EntityNamespace %>.<%= p.ClassName.ToSafeName() %>> <%= p.ContextName.ToSafeName() %> { get; set; }
|
|
<% } // foreach %>
|
|
}
|
|
|
|
<% } // if interface %>
|
|
public partial class <%= EntityContext.ClassName.ToSafeName() %>: DbContext<%= InterfaceMode ? ", I" + EntityContext.ClassName.ToSafeName() : string.Empty %>
|
|
{
|
|
static <%= EntityContext.ClassName.ToSafeName() %>()
|
|
{
|
|
Database.SetInitializer< <%= EntityContext.ClassName.ToSafeName() %>>(null);
|
|
}
|
|
public <%= EntityContext.ClassName.ToSafeName() %>()
|
|
:base("Name=<%= EntityContext.ClassName.ToSafeName() %>")
|
|
{ }
|
|
|
|
public <%= EntityContext.ClassName.ToSafeName() %>(string nameOrConnectionString)
|
|
: base(nameOrConnectionString)
|
|
{ }
|
|
|
|
<% foreach(var p in EntityContext.Entities) { %>
|
|
public System.Data.Entity.<%= InterfaceMode ? "I" : "" %>DbSet<<%= p.ClassName.ToSafeName() %>> <%= p.ContextName.ToSafeName() %> { get; set; }
|
|
<% } // foreach %>
|
|
|
|
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
|
{
|
|
<% foreach(var p in EntityContext.Entities) { %>
|
|
modelBuilder.Configurations.Add(new <%= p.MappingName.ToSafeName() %>());
|
|
<% } // foreach %>
|
|
|
|
// InitializeMapping(modelBuilder);
|
|
}
|
|
<% if (InterfaceMode) { %>
|
|
|
|
System.Data.Entity.IDbSet<TEntity> IDbContext.Set<TEntity>()
|
|
{
|
|
return base.Set<TEntity>();
|
|
}
|
|
<% } // if interface %>
|
|
}
|
|
} |