mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
50 lines
1.7 KiB
Plaintext
50 lines
1.7 KiB
Plaintext
<%--
|
|
Name: 数据访问
|
|
Author: yubaolee
|
|
Description:
|
|
--%>
|
|
<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="数据访问" %>
|
|
<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
|
|
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
|
|
<%@ Assembly Name="SchemaExplorer" %>
|
|
<%@ Import Namespace="SchemaExplorer" %>
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using OpenAuth.Domain;
|
|
using OpenAuth.Domain.Interface;
|
|
|
|
namespace OpenAuth.Repository
|
|
{
|
|
public class <%=ModuleName%>Repository :BaseRepository<<%=ModuleName%>>, I<%=ModuleName%>Repository
|
|
{
|
|
|
|
public IEnumerable<<%=ModuleName%>> Load<%=ModuleName%>s(int pageindex, int pagesize)
|
|
{
|
|
return Context.<%=ModuleName%>s.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
|
}
|
|
|
|
public IEnumerable<<%=ModuleName%>> LoadInOrgs(params int[] orgId)
|
|
{
|
|
var result = from <%=ModuleName.ToLower()%> in Context.<%=ModuleName%>s where orgId.Contains(<%=ModuleName.ToLower()%>.Id)
|
|
select <%=ModuleName.ToLower()%>;
|
|
return result;
|
|
|
|
}
|
|
|
|
public int Get<%=ModuleName%>CntInOrgs(params int[] orgIds)
|
|
{
|
|
return LoadInOrgs(orgIds).Count();
|
|
}
|
|
|
|
public IEnumerable<<%=ModuleName%>> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds)
|
|
{
|
|
return LoadInOrgs(orgIds).OrderBy(u =>u.Id).Skip((pageindex -1)*pagesize).Take(pagesize);
|
|
}
|
|
|
|
public void Delete(int id)
|
|
{
|
|
Delete(u =>u.Id == id);
|
|
}
|
|
}
|
|
}
|