mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
新增首页、文档页的静态页面
This commit is contained in:
44
Examples/website/FreeSql.Site.DAL/AppSettingsManager.cs
Normal file
44
Examples/website/FreeSql.Site.DAL/AppSettingsManager.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace FreeSql.Site.DAL
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置管理器
|
||||
/// </summary>
|
||||
public static class AppSettingsManager
|
||||
{
|
||||
private static IConfiguration _configuration;
|
||||
|
||||
static AppSettingsManager()
|
||||
{
|
||||
BuildConfiguration();
|
||||
}
|
||||
|
||||
private static void BuildConfiguration()
|
||||
{
|
||||
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json", false).AddJsonFile("appsettings.Development.json", true);
|
||||
_configuration = builder.Build();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取指定节点信息
|
||||
/// </summary>
|
||||
/// <param name="key">节点名称,多节点以:分隔</param>
|
||||
public static string Get(string key)
|
||||
{
|
||||
return _configuration[key];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取指定节点信息
|
||||
/// </summary>
|
||||
public static T Get<T>(string key)
|
||||
{
|
||||
string json = Get(key);
|
||||
return JsonConvert.DeserializeObject<T>(json);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace FreeSql.Site.DAL
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
13
Examples/website/FreeSql.Site.DAL/Db.cs
Normal file
13
Examples/website/FreeSql.Site.DAL/Db.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace FreeSql.Site.DAL
|
||||
{
|
||||
public class Db
|
||||
{
|
||||
|
||||
public static IFreeSql mysql = new FreeSql.FreeSqlBuilder()
|
||||
.UseConnectionString(FreeSql.DataType.MySql, AppSettingsManager.Get("ConnectionStrings:DefaultDbContext"))
|
||||
.Build();
|
||||
|
||||
}
|
||||
}
|
35
Examples/website/FreeSql.Site.DAL/DocumentTypeDAL.cs
Normal file
35
Examples/website/FreeSql.Site.DAL/DocumentTypeDAL.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using FreeSql.Site.Entity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
|
||||
namespace FreeSql.Site.DAL
|
||||
{
|
||||
public class DocumentTypeDAL
|
||||
{
|
||||
public long Insert(DocumentType model)
|
||||
{
|
||||
return Db.mysql.Insert<DocumentType>(model).ExecuteIdentity();
|
||||
}
|
||||
|
||||
public bool Update(DocumentType model)
|
||||
{
|
||||
return Db.mysql.Update<DocumentType>(model.ID).ExecuteUpdated().Count > 0;
|
||||
}
|
||||
|
||||
public bool Delete(long id)
|
||||
{
|
||||
return Db.mysql.Delete<DocumentType>(id).ExecuteDeleted().Count > 0;
|
||||
}
|
||||
|
||||
public List<DocumentType> Query(Expression<Func<DocumentType, bool>> where,
|
||||
Expression<Func<DocumentType, DocumentType>> orderby = null)
|
||||
{
|
||||
var list = Db.mysql.Select<DocumentType>()
|
||||
.Where(where);
|
||||
if (orderby != null) list = list.OrderBy(b => b.CreateDt);
|
||||
return list.ToList();
|
||||
}
|
||||
}
|
||||
}
|
@ -4,8 +4,16 @@
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\FreeSql\FreeSql.csproj" />
|
||||
<ProjectReference Include="..\FreeSql.Site.Entity\FreeSql.Site.Entity.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Reference in New Issue
Block a user