全面修改Id为Guid类型,为2.0版做准备

This commit is contained in:
yubaolee
2016-09-02 18:05:17 +08:00
parent a8fd59e247
commit 574f5f9e1f
327 changed files with 10071 additions and 18206 deletions

View File

@@ -5,12 +5,13 @@ using System.Linq;
using System.Linq.Expressions;
using EntityFramework.Extensions;
using OpenAuth.Domain.Interface;
using OpenAuth.Repository.Models;
using Infrastructure;
using OpenAuth.Domain;
using OpenAuth.Repository.Models;
namespace OpenAuth.Repository
{
public class BaseRepository<T> :IRepository<T> where T :class
public class BaseRepository<T> :IRepository<T> where T :Domain.Entity
{
protected OpenAuthDBContext Context = new OpenAuthDBContext();
@@ -62,6 +63,7 @@ namespace OpenAuth.Repository
public void Add(T entity)
{
entity.Id = Guid.NewGuid();
Context.Set<T>().Add(entity);
Save();
}
@@ -72,6 +74,10 @@ namespace OpenAuth.Repository
/// <param name="entities">The entities.</param>
public void BatchAdd(T[] entities)
{
foreach (var entity in entities)
{
entity.Id = Guid.NewGuid();
}
Context.Set<T>().AddRange(entities);
Save();
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
@@ -13,7 +14,7 @@ namespace OpenAuth.Repository
return Context.Categories.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public IEnumerable<Category> LoadInOrgs(params int[] orgId)
public IEnumerable<Category> LoadInOrgs(params Guid[] orgId)
{
var result = from category in Context.Categories where orgId.Contains(category.Id)
select category;
@@ -21,17 +22,17 @@ namespace OpenAuth.Repository
}
public int GetCategoryCntInOrgs(params int[] orgIds)
public int GetCategoryCntInOrgs(params Guid[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public IEnumerable<Category> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds)
public IEnumerable<Category> LoadInOrgs(int pageindex, int pagesize, params Guid[] orgIds)
{
return LoadInOrgs(orgIds).OrderBy(u =>u.Id).Skip((pageindex -1)*pagesize).Take(pagesize);
}
public void Delete(int id)
public void Delete(Guid id)
{
Delete(u =>u.Id == id);
}

View File

@@ -1,43 +1,58 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
//------------------------------------------------------------------------------
// <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 OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class CategoryMap : EntityTypeConfiguration<Category>
public partial class CategoryMap
: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Category>
{
public CategoryMap()
{
// Primary Key
this.HasKey(t => t.Id);
// table
ToTable("Category", "dbo");
// keys
HasKey(t => t.Id);
// Properties
this.Property(t => t.CascadeId)
.IsRequired()
.HasMaxLength(255);
Property(t => t.Id)
.HasColumnName("Id")
.IsRequired();
Property(t => t.CascadeId)
.HasColumnName("CascadeId")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Name)
.HasColumnName("Name")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Status)
.HasColumnName("Status")
.IsRequired();
Property(t => t.SortNo)
.HasColumnName("SortNo")
.IsRequired();
Property(t => t.RootKey)
.HasColumnName("RootKey")
.HasMaxLength(100)
.IsRequired();
Property(t => t.RootName)
.HasColumnName("RootName")
.HasMaxLength(200)
.IsRequired();
Property(t => t.ParentId)
.HasColumnName("ParentId")
.IsOptional();
this.Property(t => t.Name)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.RootKey)
.IsRequired()
.HasMaxLength(100);
this.Property(t => t.RootName)
.IsRequired()
.HasMaxLength(200);
// Table & Column Mappings
this.ToTable("Category");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.CascadeId).HasColumnName("CascadeId");
this.Property(t => t.Name).HasColumnName("Name");
this.Property(t => t.ParentId).HasColumnName("ParentId");
this.Property(t => t.Status).HasColumnName("Status");
this.Property(t => t.SortNo).HasColumnName("SortNo");
this.Property(t => t.RootKey).HasColumnName("RootKey");
this.Property(t => t.RootName).HasColumnName("RootName");
// Relationships
}
}
}

View File

@@ -1,38 +1,54 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
//------------------------------------------------------------------------------
// <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 OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class DicDetailMap : EntityTypeConfiguration<DicDetail>
public partial class DicDetailMap
: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<DicDetail>
{
public DicDetailMap()
{
// Primary Key
this.HasKey(t => t.Id);
// table
ToTable("DicDetail", "dbo");
// keys
HasKey(t => t.Id);
// Properties
this.Property(t => t.Value)
.IsRequired()
.HasMaxLength(100);
Property(t => t.Id)
.HasColumnName("Id")
.IsRequired();
Property(t => t.Value)
.HasColumnName("Value")
.HasMaxLength(100)
.IsRequired();
Property(t => t.Text)
.HasColumnName("Text")
.HasMaxLength(100)
.IsRequired();
Property(t => t.SortNo)
.HasColumnName("SortNo")
.IsRequired();
Property(t => t.Status)
.HasColumnName("Status")
.IsRequired();
Property(t => t.Description)
.HasColumnName("Description")
.HasMaxLength(100)
.IsRequired();
Property(t => t.DicId)
.HasColumnName("DicId")
.IsRequired();
this.Property(t => t.Text)
.IsRequired()
.HasMaxLength(100);
this.Property(t => t.Description)
.IsRequired()
.HasMaxLength(100);
// Table & Column Mappings
this.ToTable("DicDetail");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.Value).HasColumnName("Value");
this.Property(t => t.Text).HasColumnName("Text");
this.Property(t => t.DicId).HasColumnName("DicId");
this.Property(t => t.SortNo).HasColumnName("SortNo");
this.Property(t => t.Status).HasColumnName("Status");
this.Property(t => t.Description).HasColumnName("Description");
// Relationships
}
}
}

View File

@@ -1,37 +1,51 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
//------------------------------------------------------------------------------
// <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 OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class DicIndexMap : EntityTypeConfiguration<DicIndex>
public partial class DicIndexMap
: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<DicIndex>
{
public DicIndexMap()
{
// Primary Key
this.HasKey(t => t.Id);
// table
ToTable("DicIndex", "dbo");
// keys
HasKey(t => t.Id);
// Properties
this.Property(t => t.Name)
.IsRequired()
.HasMaxLength(255);
Property(t => t.Id)
.HasColumnName("Id")
.IsRequired();
Property(t => t.Name)
.HasColumnName("Name")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Key)
.HasColumnName("Key")
.HasMaxLength(100)
.IsRequired();
Property(t => t.SortNo)
.HasColumnName("SortNo")
.IsRequired();
Property(t => t.Description)
.HasColumnName("Description")
.HasMaxLength(200)
.IsRequired();
Property(t => t.CategoryId)
.HasColumnName("CategoryId")
.IsOptional();
this.Property(t => t.Key)
.IsRequired()
.HasMaxLength(100);
this.Property(t => t.Description)
.IsRequired()
.HasMaxLength(200);
// Table & Column Mappings
this.ToTable("DicIndex");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.Name).HasColumnName("Name");
this.Property(t => t.Key).HasColumnName("Key");
this.Property(t => t.SortNo).HasColumnName("SortNo");
this.Property(t => t.CategoryId).HasColumnName("CategoryId");
this.Property(t => t.Description).HasColumnName("Description");
// Relationships
}
}
}

View File

@@ -0,0 +1,62 @@
//------------------------------------------------------------------------------
// <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.ComponentModel.DataAnnotations.Schema;
using OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public partial class GoodsApplyMap
: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<GoodsApply>
{
public GoodsApplyMap()
{
// table
ToTable("GoodsApply", "dbo");
// keys
HasKey(t => t.Id);
// Properties
Property(t => t.Id)
.HasColumnName("Id")
.IsRequired();
Property(t => t.Sort)
.HasColumnName("Sort")
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
.IsRequired();
Property(t => t.Number)
.HasColumnName("Number")
.IsRequired();
Property(t => t.Name)
.HasColumnName("Name")
.HasMaxLength(256)
.IsOptional();
Property(t => t.Comment)
.HasColumnName("Comment")
.IsRequired();
Property(t => t.State)
.HasColumnName("State")
.HasMaxLength(1024)
.IsRequired();
Property(t => t.StateName)
.HasColumnName("StateName")
.HasMaxLength(1024)
.IsOptional();
Property(t => t.UserId)
.HasColumnName("UserId")
.IsRequired();
Property(t => t.ControllerUserId)
.HasColumnName("ControllerUserId")
.IsOptional();
// Relationships
}
}
}

View File

@@ -1,62 +1,71 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
//------------------------------------------------------------------------------
// <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 OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class ModuleElementMap : EntityTypeConfiguration<ModuleElement>
public partial class ModuleElementMap
: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<ModuleElement>
{
public ModuleElementMap()
{
// Primary Key
this.HasKey(t => t.Id);
// table
ToTable("ModuleElement", "dbo");
// keys
HasKey(t => t.Id);
// Properties
this.Property(t => t.DomId)
.IsRequired()
.HasMaxLength(255);
Property(t => t.Id)
.HasColumnName("Id")
.IsRequired();
Property(t => t.DomId)
.HasColumnName("DomId")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Name)
.HasColumnName("Name")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Type)
.HasColumnName("Type")
.HasMaxLength(50)
.IsRequired();
Property(t => t.Attr)
.HasColumnName("Attr")
.HasMaxLength(500)
.IsRequired();
Property(t => t.Script)
.HasColumnName("Script")
.HasMaxLength(500)
.IsRequired();
Property(t => t.Icon)
.HasColumnName("Icon")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Class)
.HasColumnName("Class")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Remark)
.HasColumnName("Remark")
.HasMaxLength(200)
.IsRequired();
Property(t => t.Sort)
.HasColumnName("Sort")
.IsRequired();
Property(t => t.ModuleId)
.HasColumnName("ModuleId")
.IsRequired();
this.Property(t => t.Name)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Type)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.Attr)
.IsRequired()
.HasMaxLength(500);
this.Property(t => t.Script)
.IsRequired()
.HasMaxLength(500);
this.Property(t => t.Icon)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Class)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Remark)
.IsRequired()
.HasMaxLength(200);
// Table & Column Mappings
this.ToTable("ModuleElement");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.DomId).HasColumnName("DomId");
this.Property(t => t.Name).HasColumnName("Name");
this.Property(t => t.Type).HasColumnName("Type");
this.Property(t => t.ModuleId).HasColumnName("ModuleId");
this.Property(t => t.Attr).HasColumnName("Attr");
this.Property(t => t.Script).HasColumnName("Script");
this.Property(t => t.Icon).HasColumnName("Icon");
this.Property(t => t.Class).HasColumnName("Class");
this.Property(t => t.Remark).HasColumnName("Remark");
this.Property(t => t.Sort).HasColumnName("Sort");
// Relationships
}
}
}

View File

@@ -1,60 +1,76 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
//------------------------------------------------------------------------------
// <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 OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class ModuleMap : EntityTypeConfiguration<Module>
public partial class ModuleMap
: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Module>
{
public ModuleMap()
{
// Primary Key
this.HasKey(t => t.Id);
// table
ToTable("Module", "dbo");
// keys
HasKey(t => t.Id);
// Properties
this.Property(t => t.CascadeId)
.IsRequired()
.HasMaxLength(255);
Property(t => t.Id)
.HasColumnName("Id")
.IsRequired();
Property(t => t.CascadeId)
.HasColumnName("CascadeId")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Name)
.HasColumnName("Name")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Url)
.HasColumnName("Url")
.HasMaxLength(255)
.IsRequired();
Property(t => t.HotKey)
.HasColumnName("HotKey")
.HasMaxLength(255)
.IsRequired();
Property(t => t.ParentId)
.HasColumnName("ParentId")
.IsRequired();
Property(t => t.IsLeaf)
.HasColumnName("IsLeaf")
.IsRequired();
Property(t => t.IsAutoExpand)
.HasColumnName("IsAutoExpand")
.IsRequired();
Property(t => t.IconName)
.HasColumnName("IconName")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Status)
.HasColumnName("Status")
.IsRequired();
Property(t => t.ParentName)
.HasColumnName("ParentName")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Vector)
.HasColumnName("Vector")
.HasMaxLength(255)
.IsRequired();
Property(t => t.SortNo)
.HasColumnName("SortNo")
.IsRequired();
this.Property(t => t.Name)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Url)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.HotKey)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.IconName)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.ParentName)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Vector)
.IsRequired()
.HasMaxLength(255);
// Table & Column Mappings
this.ToTable("Module");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.CascadeId).HasColumnName("CascadeId");
this.Property(t => t.Name).HasColumnName("Name");
this.Property(t => t.Url).HasColumnName("Url");
this.Property(t => t.HotKey).HasColumnName("HotKey");
this.Property(t => t.ParentId).HasColumnName("ParentId");
this.Property(t => t.IsLeaf).HasColumnName("IsLeaf");
this.Property(t => t.IsAutoExpand).HasColumnName("IsAutoExpand");
this.Property(t => t.IconName).HasColumnName("IconName");
this.Property(t => t.Status).HasColumnName("Status");
this.Property(t => t.ParentName).HasColumnName("ParentName");
this.Property(t => t.Vector).HasColumnName("Vector");
this.Property(t => t.SortNo).HasColumnName("SortNo");
// Relationships
}
}
}

View File

@@ -1,63 +1,85 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
//------------------------------------------------------------------------------
// <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 OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class OrgMap : EntityTypeConfiguration<Org>
public partial class OrgMap
: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Org>
{
public OrgMap()
{
// Primary Key
this.HasKey(t => t.Id);
// table
ToTable("Org", "dbo");
// keys
HasKey(t => t.Id);
// Properties
this.Property(t => t.CascadeId)
.IsRequired()
.HasMaxLength(255);
Property(t => t.Id)
.HasColumnName("Id")
.IsRequired();
Property(t => t.CascadeId)
.HasColumnName("CascadeId")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Name)
.HasColumnName("Name")
.HasMaxLength(255)
.IsRequired();
Property(t => t.HotKey)
.HasColumnName("HotKey")
.HasMaxLength(255)
.IsRequired();
Property(t => t.ParentName)
.HasColumnName("ParentName")
.HasMaxLength(255)
.IsRequired();
Property(t => t.IsLeaf)
.HasColumnName("IsLeaf")
.IsRequired();
Property(t => t.IsAutoExpand)
.HasColumnName("IsAutoExpand")
.IsRequired();
Property(t => t.IconName)
.HasColumnName("IconName")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Status)
.HasColumnName("Status")
.IsRequired();
Property(t => t.Type)
.HasColumnName("Type")
.IsRequired();
Property(t => t.BizCode)
.HasColumnName("BizCode")
.HasMaxLength(255)
.IsRequired();
Property(t => t.CustomCode)
.HasColumnName("CustomCode")
.HasMaxLength(4000)
.IsRequired();
Property(t => t.CreateTime)
.HasColumnName("CreateTime")
.IsRequired();
Property(t => t.CreateId)
.HasColumnName("CreateId")
.IsRequired();
Property(t => t.SortNo)
.HasColumnName("SortNo")
.IsRequired();
Property(t => t.ParentId)
.HasColumnName("ParentId")
.IsOptional();
this.Property(t => t.Name)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.HotKey)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.ParentName)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.IconName)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.BizCode)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.CustomCode)
.IsRequired()
.HasMaxLength(4000);
// Table & Column Mappings
this.ToTable("Org");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.CascadeId).HasColumnName("CascadeId");
this.Property(t => t.Name).HasColumnName("Name");
this.Property(t => t.HotKey).HasColumnName("HotKey");
this.Property(t => t.ParentId).HasColumnName("ParentId");
this.Property(t => t.ParentName).HasColumnName("ParentName");
this.Property(t => t.IsLeaf).HasColumnName("IsLeaf");
this.Property(t => t.IsAutoExpand).HasColumnName("IsAutoExpand");
this.Property(t => t.IconName).HasColumnName("IconName");
this.Property(t => t.Status).HasColumnName("Status");
this.Property(t => t.Type).HasColumnName("Type");
this.Property(t => t.BizCode).HasColumnName("BizCode");
this.Property(t => t.CustomCode).HasColumnName("CustomCode");
this.Property(t => t.CreateTime).HasColumnName("CreateTime");
this.Property(t => t.CreateId).HasColumnName("CreateId");
this.Property(t => t.SortNo).HasColumnName("SortNo");
// Relationships
}
}
}

View File

@@ -1,38 +0,0 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class ParamMap : EntityTypeConfiguration<Param>
{
public ParamMap()
{
// Primary Key
this.HasKey(t => t.Id);
// Properties
this.Property(t => t.Value)
.IsRequired()
.HasMaxLength(100);
this.Property(t => t.Key)
.IsRequired()
.HasMaxLength(100);
this.Property(t => t.Description)
.IsRequired()
.HasMaxLength(100);
// Table & Column Mappings
this.ToTable("Param");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.Value).HasColumnName("Value");
this.Property(t => t.Key).HasColumnName("Key");
this.Property(t => t.CategoryId).HasColumnName("CategoryId");
this.Property(t => t.SortNo).HasColumnName("SortNo");
this.Property(t => t.Status).HasColumnName("Status");
this.Property(t => t.Description).HasColumnName("Description");
}
}
}

View File

@@ -1,35 +1,56 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
//------------------------------------------------------------------------------
// <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 OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class RelevanceMap : EntityTypeConfiguration<Relevance>
public partial class RelevanceMap
: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Relevance>
{
public RelevanceMap()
{
// Primary Key
this.HasKey(t => t.Id);
// table
ToTable("Relevance", "dbo");
// keys
HasKey(t => t.Id);
// Properties
this.Property(t => t.Description)
.IsRequired()
.HasMaxLength(100);
Property(t => t.Id)
.HasColumnName("Id")
.IsRequired();
Property(t => t.Description)
.HasColumnName("Description")
.HasMaxLength(100)
.IsRequired();
Property(t => t.Key)
.HasColumnName("Key")
.HasMaxLength(100)
.IsRequired();
Property(t => t.Status)
.HasColumnName("Status")
.IsRequired();
Property(t => t.OperateTime)
.HasColumnName("OperateTime")
.IsRequired();
Property(t => t.OperatorId)
.HasColumnName("OperatorId")
.IsRequired();
Property(t => t.FirstId)
.HasColumnName("FirstId")
.IsRequired();
Property(t => t.SecondId)
.HasColumnName("SecondId")
.IsRequired();
this.Property(t => t.Key)
.IsRequired()
.HasMaxLength(100);
// Table & Column Mappings
this.ToTable("Relevance");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.FirstId).HasColumnName("FirstId");
this.Property(t => t.SecondId).HasColumnName("SecondId");
this.Property(t => t.Description).HasColumnName("Description");
this.Property(t => t.Key).HasColumnName("Key");
this.Property(t => t.Status).HasColumnName("Status");
this.Property(t => t.OperateTime).HasColumnName("OperateTime");
this.Property(t => t.OperatorId).HasColumnName("OperatorId");
// Relationships
}
}
}

View File

@@ -1,44 +1,61 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
//------------------------------------------------------------------------------
// <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 OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class ResourceMap : EntityTypeConfiguration<Resource>
public partial class ResourceMap
: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Resource>
{
public ResourceMap()
{
// Primary Key
this.HasKey(t => t.Id);
// table
ToTable("Resource", "dbo");
// keys
HasKey(t => t.Id);
// Properties
this.Property(t => t.CascadeId)
.IsRequired()
.HasMaxLength(255);
Property(t => t.Id)
.HasColumnName("Id")
.IsRequired();
Property(t => t.CascadeId)
.HasColumnName("CascadeId")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Key)
.HasColumnName("Key")
.HasMaxLength(200)
.IsRequired();
Property(t => t.Name)
.HasColumnName("Name")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Status)
.HasColumnName("Status")
.IsRequired();
Property(t => t.SortNo)
.HasColumnName("SortNo")
.IsRequired();
Property(t => t.CategoryId)
.HasColumnName("CategoryId")
.IsRequired();
Property(t => t.Description)
.HasColumnName("Description")
.HasMaxLength(500)
.IsRequired();
Property(t => t.ParentId)
.HasColumnName("ParentId")
.IsOptional();
this.Property(t => t.Key)
.IsRequired()
.HasMaxLength(200);
this.Property(t => t.Name)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Description)
.IsRequired()
.HasMaxLength(500);
// Table & Column Mappings
this.ToTable("Resource");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.CascadeId).HasColumnName("CascadeId");
this.Property(t => t.Key).HasColumnName("Key");
this.Property(t => t.Name).HasColumnName("Name");
this.Property(t => t.ParentId).HasColumnName("ParentId");
this.Property(t => t.Status).HasColumnName("Status");
this.Property(t => t.SortNo).HasColumnName("SortNo");
this.Property(t => t.CategoryId).HasColumnName("CategoryId");
this.Property(t => t.Description).HasColumnName("Description");
// Relationships
}
}
}

View File

@@ -1,44 +1,61 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
//------------------------------------------------------------------------------
// <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 OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class RoleMap : EntityTypeConfiguration<Role>
public partial class RoleMap
: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Role>
{
public RoleMap()
{
// Primary Key
this.HasKey(t => t.Id);
// table
ToTable("Role", "dbo");
// keys
HasKey(t => t.Id);
// Properties
this.Property(t => t.Name)
.IsRequired()
.HasMaxLength(255);
Property(t => t.Id)
.HasColumnName("Id")
.IsRequired();
Property(t => t.Name)
.HasColumnName("Name")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Status)
.HasColumnName("Status")
.IsRequired();
Property(t => t.Type)
.HasColumnName("Type")
.IsRequired();
Property(t => t.CreateTime)
.HasColumnName("CreateTime")
.IsRequired();
Property(t => t.CreateId)
.HasColumnName("CreateId")
.HasMaxLength(64)
.IsRequired();
Property(t => t.OrgCascadeId)
.HasColumnName("OrgCascadeId")
.HasMaxLength(255)
.IsRequired();
Property(t => t.OrgName)
.HasColumnName("OrgName")
.HasMaxLength(255)
.IsRequired();
Property(t => t.OrgId)
.HasColumnName("OrgId")
.IsOptional();
this.Property(t => t.CreateId)
.IsRequired()
.HasMaxLength(64);
this.Property(t => t.OrgCascadeId)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.OrgName)
.IsRequired()
.HasMaxLength(255);
// Table & Column Mappings
this.ToTable("Role");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.Name).HasColumnName("Name");
this.Property(t => t.Status).HasColumnName("Status");
this.Property(t => t.Type).HasColumnName("Type");
this.Property(t => t.CreateTime).HasColumnName("CreateTime");
this.Property(t => t.CreateId).HasColumnName("CreateId");
this.Property(t => t.OrgId).HasColumnName("OrgId");
this.Property(t => t.OrgCascadeId).HasColumnName("OrgCascadeId");
this.Property(t => t.OrgName).HasColumnName("OrgName");
// Relationships
}
}
}

View File

@@ -6,14 +6,13 @@
// file will be lost if the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public partial class StockMap
: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<OpenAuth.Domain.Stock>
: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Stock>
{
public StockMap()
{
@@ -41,13 +40,16 @@ namespace OpenAuth.Repository.Models.Mapping
Property(t => t.Status)
.HasColumnName("Status")
.IsRequired();
Property(t => t.User)
.HasColumnName("User")
Property(t => t.Viewable)
.HasColumnName("Viewable")
.HasMaxLength(50)
.IsRequired();
Property(t => t.Time)
.HasColumnName("Time")
.IsRequired();
Property(t => t.OrgId)
.HasColumnName("OrgId")
.IsOptional();
// Relationships
}

View File

@@ -1,41 +0,0 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class UserCfgMap : EntityTypeConfiguration<UserCfg>
{
public UserCfgMap()
{
// Primary Key
this.HasKey(t => t.Id);
// Properties
this.Property(t => t.Theme)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Skin)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.NavBarStyle)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.TabFocusColor)
.IsRequired()
.HasMaxLength(255);
// Table & Column Mappings
this.ToTable("UserCfg");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.Theme).HasColumnName("Theme");
this.Property(t => t.Skin).HasColumnName("Skin");
this.Property(t => t.NavBarStyle).HasColumnName("NavBarStyle");
this.Property(t => t.TabFocusColor).HasColumnName("TabFocusColor");
this.Property(t => t.NavTabIndex).HasColumnName("NavTabIndex");
}
}
}

View File

@@ -1,86 +0,0 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class UserExtMap : EntityTypeConfiguration<UserExt>
{
public UserExtMap()
{
// Primary Key
this.HasKey(t => t.Id);
// Properties
this.Property(t => t.Email)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Phone)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Mobile)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Address)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Zip)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Birthday)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.IdCard)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Qq)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.DynamicField)
.IsRequired()
.HasMaxLength(4000);
this.Property(t => t.Remark)
.IsRequired()
.HasMaxLength(4000);
this.Property(t => t.Field1)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Field2)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Field3)
.IsRequired()
.HasMaxLength(255);
// Table & Column Mappings
this.ToTable("UserExt");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.Email).HasColumnName("Email");
this.Property(t => t.Phone).HasColumnName("Phone_");
this.Property(t => t.Mobile).HasColumnName("Mobile");
this.Property(t => t.Address).HasColumnName("Address");
this.Property(t => t.Zip).HasColumnName("Zip");
this.Property(t => t.Birthday).HasColumnName("Birthday");
this.Property(t => t.IdCard).HasColumnName("IdCard");
this.Property(t => t.Qq).HasColumnName("QQ");
this.Property(t => t.DynamicField).HasColumnName("DynamicField");
this.Property(t => t.ByteArrayId).HasColumnName("ByteArrayId");
this.Property(t => t.Remark).HasColumnName("Remark");
this.Property(t => t.Field1).HasColumnName("Field1");
this.Property(t => t.Field2).HasColumnName("Field2");
this.Property(t => t.Field3).HasColumnName("Field3");
}
}
}

View File

@@ -1,45 +1,66 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
//------------------------------------------------------------------------------
// <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 OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class UserMap : EntityTypeConfiguration<User>
public partial class UserMap
: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<User>
{
public UserMap()
{
// Primary Key
this.HasKey(t => t.Id);
// table
ToTable("User", "dbo");
// keys
HasKey<Guid>(t => t.Id);
// Properties
this.Property(t => t.Account)
.IsRequired()
.HasMaxLength(255);
Property(t => t.Id)
.HasColumnName("Id")
.IsRequired();
Property(t => t.Account)
.HasColumnName("Account")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Password)
.HasColumnName("Password")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Name)
.HasColumnName("Name")
.HasMaxLength(255)
.IsRequired();
Property(t => t.Sex)
.HasColumnName("Sex")
.IsRequired();
Property(t => t.Status)
.HasColumnName("Status")
.IsRequired();
Property(t => t.Type)
.HasColumnName("Type")
.IsRequired();
Property(t => t.BizCode)
.HasColumnName("BizCode")
.HasMaxLength(255)
.IsRequired();
Property(t => t.CreateTime)
.HasColumnName("CreateTime")
.IsRequired();
Property(t => t.CrateId)
.HasColumnName("CrateId")
.IsOptional();
this.Property(t => t.Password)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Name)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.BizCode)
.IsRequired()
.HasMaxLength(255);
// Table & Column Mappings
this.ToTable("User");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.Account).HasColumnName("Account");
this.Property(t => t.Password).HasColumnName("Password");
this.Property(t => t.Name).HasColumnName("Name");
this.Property(t => t.Sex).HasColumnName("Sex");
this.Property(t => t.Status).HasColumnName("Status");
this.Property(t => t.Type).HasColumnName("Type");
this.Property(t => t.BizCode).HasColumnName("BizCode");
this.Property(t => t.CreateTime).HasColumnName("CreateTime");
this.Property(t => t.CreateId).HasColumnName("CreateId");
// Relationships
}
}
}

View File

@@ -1,55 +1,60 @@
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
//------------------------------------------------------------------------------
// <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.Data.Entity;
using OpenAuth.Domain;
using OpenAuth.Repository.Models.Mapping;
namespace OpenAuth.Repository.Models
{
public partial class OpenAuthDBContext : DbContext
public partial class OpenAuthDBContext: DbContext
{
static OpenAuthDBContext()
static OpenAuthDBContext()
{
Database.SetInitializer<OpenAuthDBContext>(null);
Database.SetInitializer< OpenAuthDBContext>(null);
}
public OpenAuthDBContext()
: base("Name=OpenAuthDBContext")
{
}
:base("Name=OpenAuthDBContext")
{ }
public DbSet<Category> Categories { get; set; }
public DbSet<DicDetail> DicDetails { get; set; }
public DbSet<DicIndex> DicIndexes { get; set; }
public DbSet<Module> Modules { get; set; }
public DbSet<ModuleElement> ModuleElements { get; set; }
public DbSet<Org> Orgs { get; set; }
public DbSet<Param> Params { get; set; }
public DbSet<Relevance> Relevances { get; set; }
public DbSet<Resource> Resources { get; set; }
public DbSet<Role> Roles { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<UserCfg> UserCfgs { get; set; }
public DbSet<UserExt> UserExts { get; set; }
public OpenAuthDBContext(string nameOrConnectionString)
: base(nameOrConnectionString)
{ }
public DbSet<Stock> Stocks { get; set; }
public System.Data.Entity.DbSet<Category> Categories { get; set; }
public System.Data.Entity.DbSet<DicDetail> DicDetails { get; set; }
public System.Data.Entity.DbSet<DicIndex> DicIndices { get; set; }
public System.Data.Entity.DbSet<GoodsApply> GoodsApplies { get; set; }
public System.Data.Entity.DbSet<Module> Modules { get; set; }
public System.Data.Entity.DbSet<ModuleElement> ModuleElements { get; set; }
public System.Data.Entity.DbSet<Org> Orgs { get; set; }
public System.Data.Entity.DbSet<Relevance> Relevances { get; set; }
public System.Data.Entity.DbSet<Resource> Resources { get; set; }
public System.Data.Entity.DbSet<Role> Roles { get; set; }
public System.Data.Entity.DbSet<Stock> Stocks { get; set; }
public System.Data.Entity.DbSet<User> Users { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new CategoryMap());
modelBuilder.Configurations.Add(new DicDetailMap());
modelBuilder.Configurations.Add(new DicIndexMap());
modelBuilder.Configurations.Add(new GoodsApplyMap());
modelBuilder.Configurations.Add(new ModuleMap());
modelBuilder.Configurations.Add(new ModuleElementMap());
modelBuilder.Configurations.Add(new OrgMap());
modelBuilder.Configurations.Add(new ParamMap());
modelBuilder.Configurations.Add(new RelevanceMap());
modelBuilder.Configurations.Add(new ResourceMap());
modelBuilder.Configurations.Add(new RoleMap());
modelBuilder.Configurations.Add(new UserMap());
modelBuilder.Configurations.Add(new UserCfgMap());
modelBuilder.Configurations.Add(new UserExtMap());
modelBuilder.Configurations.Add(new StockMap());
modelBuilder.Configurations.Add(new UserMap());
}
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
@@ -12,30 +13,30 @@ namespace OpenAuth.Repository
return Context.Modules.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public int GetRoleCntInOrgs(params int[] orgIds)
public int GetRoleCntInOrgs(params Guid[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public int GetModuleCntInOrgs(params int[] orgIds)
public int GetModuleCntInOrgs(params Guid[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public IEnumerable<Module> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds)
public IEnumerable<Module> LoadInOrgs(int pageindex, int pagesize, params Guid[] orgIds)
{
return LoadInOrgs(orgIds).OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public void Delete(int id)
public void Delete(Guid id)
{
Delete(u =>u.Id == id);
}
public IEnumerable<Module> LoadInOrgs(params int[] orgId)
public IEnumerable<Module> LoadInOrgs(params Guid[] orgId)
{
var result = from role in Context.Modules.Where(u => orgId.Contains(u.ParentId)) select role;
var result = from role in Context.Modules.Where(u =>u.ParentId != null && orgId.Contains(u.ParentId.Value)) select role;
return result;

View File

@@ -55,6 +55,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Models\Mapping\GoodsApplyMap.cs" />
<Compile Include="UnitWork.cs" />
<Compile Include="BaseRepository.cs" />
<Compile Include="Models\Mapping\CategoryMap.cs" />
@@ -63,13 +64,10 @@
<Compile Include="Models\Mapping\ModuleElementMap.cs" />
<Compile Include="Models\Mapping\ModuleMap.cs" />
<Compile Include="Models\Mapping\OrgMap.cs" />
<Compile Include="Models\Mapping\ParamMap.cs" />
<Compile Include="Models\Mapping\RelevanceMap.cs" />
<Compile Include="Models\Mapping\ResourceMap.cs" />
<Compile Include="Models\Mapping\RoleMap.cs" />
<Compile Include="Models\Mapping\StockMap.cs" />
<Compile Include="Models\Mapping\UserCfgMap.cs" />
<Compile Include="Models\Mapping\UserExtMap.cs" />
<Compile Include="Models\Mapping\UserMap.cs" />
<Compile Include="Models\OpenAuthDBContext.cs" />
<Compile Include="OrgRepository.cs" />

View File

@@ -15,7 +15,7 @@ namespace OpenAuth.Repository
return Find();
}
public IEnumerable<Org> LoadByUser(int userId)
public IEnumerable<Org> LoadByUser(Guid userId)
{
var result = from userorg in Context.Relevances
join org in Context.Orgs on userorg.SecondId equals org.Id
@@ -25,10 +25,10 @@ namespace OpenAuth.Repository
}
public IEnumerable<Org> GetSubOrgs(int orgId)
public IEnumerable<Org> GetSubOrgs(Guid orgId)
{
string cascadeId = "0.";
if (orgId != 0)
if (orgId != Guid.Empty)
{
var org = FindSingle(u => u.Id == orgId);
if (org == null)
@@ -39,10 +39,10 @@ namespace OpenAuth.Repository
return Find(u => u.CascadeId.Contains(cascadeId));
}
public IEnumerable<Org> GetSubWithOwn(int orgId)
public IEnumerable<Org> GetSubWithOwn(Guid orgId)
{
string cascadeId = "0.";
if (orgId != 0)
if (orgId != Guid.Empty)
{
var org = FindSingle(u => u.Id == orgId);
if (org == null)

View File

@@ -7,7 +7,7 @@ namespace OpenAuth.Repository
{
public class RelevanceRepository : BaseRepository<Relevance>, IRelevanceRepository
{
public void DeleteBy(string key, params int[] firstIds)
public void DeleteBy(string key, params Guid[] firstIds)
{
Delete(u => firstIds.Contains(u.FirstId) && u.Key == key);
}
@@ -17,7 +17,7 @@ namespace OpenAuth.Repository
/// </summary>
/// <param name="key">关联标识</param>
/// <param name="idMaps">关联的&lt;firstId, secondId&gt;数组</param>
public void DeleteBy(string key, ILookup<int, int> idMaps)
public void DeleteBy(string key, ILookup<Guid, Guid> idMaps)
{
foreach (var sameVals in idMaps)
{
@@ -33,7 +33,7 @@ namespace OpenAuth.Repository
/// </summary>
/// <param name="key">关联标识</param>
/// <param name="idMaps">关联的&lt;firstId, secondId&gt;数组</param>
public void AddRelevance(string key, ILookup<int, int> idMaps)
public void AddRelevance(string key, ILookup<Guid, Guid> idMaps)
{
foreach (var sameVals in idMaps)
{

View File

@@ -15,24 +15,24 @@ namespace OpenAuth.Repository
return Context.Roles.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public int GetRoleCntInOrgs(params int[] orgIds)
public int GetRoleCntInOrgs(params Guid[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public IEnumerable<Role> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds)
public IEnumerable<Role> LoadInOrgs(int pageindex, int pagesize, params Guid[] orgIds)
{
return LoadInOrgs(orgIds).OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public void Delete(int id)
public void Delete(Guid id)
{
Delete(u =>u.Id == id);
}
public IEnumerable<Role> LoadInOrgs(params int[] orgId)
public IEnumerable<Role> LoadInOrgs(params Guid[] orgId)
{
var result = from role in Context.Roles.Where(u => orgId.Contains(u.OrgId)) select role;
var result = from role in Context.Roles.Where(u =>u.OrgId != null && orgId.Contains(u.OrgId.Value)) select role;
return result;

View File

@@ -1,4 +1,5 @@
using OpenAuth.Domain;
using System;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using System.Collections.Generic;
using System.Linq;
@@ -7,21 +8,21 @@ namespace OpenAuth.Repository
{
public class ResourceRepository : BaseRepository<Resource>, IResourceRepository
{
public IEnumerable<Resource> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds)
public IEnumerable<Resource> LoadInOrgs(int pageindex, int pagesize, params Guid[] orgIds)
{
return LoadInOrgs(orgIds).OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public void Delete(int id)
public void Delete(Guid id)
{
Delete(u => u.Id == id);
}
public IEnumerable<Resource> LoadInOrgs(params int[] orgId)
public IEnumerable<Resource> LoadInOrgs(params Guid[] orgId)
{
bool isZero = orgId.Length == 1 && orgId[0] == 0; //判断传进来的是否为0
bool isZero = orgId.Length == 1 && orgId[0] == Guid.Empty; //判断传进来的是否为0
var result = from resource in Context.Resources.Where(u =>isZero
|| orgId.Contains(u.CategoryId)) select resource;
|| u.CascadeId != null &&orgId.Contains(u.CategoryId.Value)) select resource;
return result;
}
@@ -31,7 +32,7 @@ namespace OpenAuth.Repository
return Context.Resources.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public int GetResourceCntInOrgs(params int[] orgIds)
public int GetResourceCntInOrgs(params Guid[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
@@ -13,25 +14,25 @@ namespace OpenAuth.Repository
return Context.Stocks.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public IEnumerable<Stock> LoadInOrgs(params int[] orgId)
public IEnumerable<Stock> LoadInOrgs(params Guid[] orgId)
{
var result = from stock in Context.Stocks where orgId.Contains(stock.OrgId)
var result = from stock in Context.Stocks where stock.OrgId != null && orgId.Contains(stock.OrgId.Value)
select stock;
return result;
}
public int GetStockCntInOrgs(params int[] orgIds)
public int GetStockCntInOrgs(params Guid[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public IEnumerable<Stock> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds)
public IEnumerable<Stock> LoadInOrgs(int pageindex, int pagesize, params Guid[] orgIds)
{
return LoadInOrgs(orgIds).OrderBy(u =>u.Id).Skip((pageindex -1)*pagesize).Take(pagesize);
}
public void Delete(int id)
public void Delete(Guid id)
{
Delete(u =>u.Id == id);
}

View File

@@ -5,8 +5,9 @@ using System.Linq;
using System.Linq.Expressions;
using EntityFramework.Extensions;
using OpenAuth.Domain.Interface;
using OpenAuth.Repository.Models;
using Infrastructure;
using OpenAuth.Domain;
using OpenAuth.Repository.Models;
namespace OpenAuth.Repository
{
@@ -19,7 +20,7 @@ namespace OpenAuth.Repository
/// 根据过滤条件,获取记录
/// </summary>
/// <param name="exp">The exp.</param>
public IQueryable<T> Find<T>(Expression<Func<T, bool>> exp = null) where T : class
public IQueryable<T> Find<T>(Expression<Func<T, bool>> exp = null) where T : class
{
return Filter(exp);
}
@@ -60,8 +61,9 @@ namespace OpenAuth.Repository
return Filter(exp).Count();
}
public void Add<T>(T entity) where T : class
public void Add<T>(T entity) where T : Domain.Entity
{
entity.Id = Guid.NewGuid();
Context.Set<T>().Add(entity);
}
@@ -69,8 +71,12 @@ namespace OpenAuth.Repository
/// 批量添加
/// </summary>
/// <param name="entities">The entities.</param>
public void BatchAdd<T>(T[] entities) where T : class
public void BatchAdd<T>(T[] entities) where T : Domain.Entity
{
foreach (var entity in entities)
{
entity.Id = Guid.NewGuid();
}
Context.Set<T>().AddRange(entities);
}

View File

@@ -8,6 +8,7 @@ using System.Transactions;
using EntityFramework.Extensions;
using OpenAuth.Domain;
namespace OpenAuth.Repository
{
public class UserRepository :BaseRepository<User>, IUserRepository
@@ -17,7 +18,7 @@ namespace OpenAuth.Repository
return Context.Users.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public IEnumerable<User> LoadInOrgs(params int[] orgId)
public IEnumerable<User> LoadInOrgs(params Guid[] orgId)
{
var result = from user in Context.Users
where (
@@ -31,12 +32,12 @@ namespace OpenAuth.Repository
}
public int GetUserCntInOrgs(params int[] orgIds)
public int GetUserCntInOrgs(params Guid[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public IEnumerable<User> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds)
public IEnumerable<User> LoadInOrgs(int pageindex, int pagesize, params Guid[] orgIds)
{
return LoadInOrgs(orgIds).OrderBy(u =>u.Id).Skip((pageindex -1)*pagesize).Take(pagesize);
}