Skip to content

Commit f0139c2

Browse files
committed
1.1.5/1.1.6
增加对主键guid和create_time/createtime 值自动生成,删除连接池相关代码
1 parent 2767122 commit f0139c2

File tree

21 files changed

+563
-301
lines changed

21 files changed

+563
-301
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@
3434
/WebApplication1/obj/Debug/netcoreapp2.2
3535
/WebApplication1/obj
3636
/.vs/config
37+
/MyStaging.xUnitTest.db/bin/Debug/netstandard2.0

.vs/MyStaging/v15/.suo

16 KB
Binary file not shown.

MyStaging.App/DAL/TablesDal.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,9 @@ void CreateConstructor(string paramString, string onChange = null)
340340
writer.WriteLine($"\t\t\t\treturn this;");
341341
writer.WriteLine("\t\t\t}");
342342

343-
writer.WriteLine($"\t\t\tpublic new {updateName} Where(string formatCommad, params object[] pValue)");
343+
writer.WriteLine($"\t\t\tpublic new {updateName} Where(string expression)");
344344
writer.WriteLine("\t\t\t{");
345-
writer.WriteLine($"\t\t\t\tbase.Where(formatCommad,pValue);");
345+
writer.WriteLine($"\t\t\t\tbase.Where(expression);");
346346
writer.WriteLine($"\t\t\t\treturn this;");
347347
writer.WriteLine("\t\t\t}");
348348

MyStaging.xUnitTest.db/DAL/Build/Article.cs

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -13,78 +13,78 @@
1313

1414
namespace MyStaging.xUnitTest.DAL
1515
{
16-
public partial class Article : QueryContext<ArticleModel>
17-
{
18-
public static Article Context { get { return new Article(); } }
16+
public partial class Article : QueryContext<ArticleModel>
17+
{
18+
public static Article Context { get { return new Article(); } }
1919

20-
public static InsertBuilder<ArticleModel> InsertBuilder => new InsertBuilder<ArticleModel>(ArticleSchema.Instance);
21-
public static ArticleModel Insert(ArticleModel model) => InsertBuilder.Insert(model);
22-
public static int InsertRange(List<ArticleModel> models) => InsertBuilder.InsertRange(models).SaveChange();
20+
public static InsertBuilder<ArticleModel> InsertBuilder => new InsertBuilder<ArticleModel>(ArticleSchema.Instance);
21+
public static ArticleModel Insert(ArticleModel model) => InsertBuilder.Insert(model);
22+
public static int InsertRange(List<ArticleModel> models) => InsertBuilder.InsertRange(models).SaveChange();
2323

24-
public static DeleteBuilder<ArticleModel> DeleteBuilder => new DeleteBuilder<ArticleModel>();
25-
public static int Delete(string id, string userid)
26-
{
27-
var affrows = DeleteBuilder.Where(f => f.Id == id && f.Userid == userid).SaveChange();
28-
if (affrows > 0) Helpers.PgSqlHelper.CacheManager?.RemoveItemCache<ArticleModel>(id);
29-
return affrows;
30-
}
24+
public static DeleteBuilder<ArticleModel> DeleteBuilder => new DeleteBuilder<ArticleModel>();
25+
public static int Delete(string id,string userid)
26+
{
27+
var affrows = DeleteBuilder.Where(f => f.Id == id && f.Userid == userid).SaveChange();
28+
if (affrows > 0) PgSqlHelper.CacheManager?.RemoveItemCache<ArticleModel>(id + "" + userid);
29+
return affrows;
30+
}
3131

32-
public static ArticleUpdateBuilder UpdateBuilder => new ArticleUpdateBuilder();
33-
public static ArticleUpdateBuilder Update(string id, string userid)
34-
{
35-
return new ArticleUpdateBuilder(null, id, userid);
36-
}
32+
public static ArticleUpdateBuilder UpdateBuilder => new ArticleUpdateBuilder();
33+
public static ArticleUpdateBuilder Update(string id,string userid)
34+
{
35+
return new ArticleUpdateBuilder(null, id,userid);
36+
}
3737

38-
public class ArticleUpdateBuilder : UpdateBuilder<ArticleModel>
39-
{
40-
public ArticleUpdateBuilder(string id, string userid)
41-
{
42-
base.Where(f => f.Id == id && f.Userid == userid);
43-
}
38+
public class ArticleUpdateBuilder : UpdateBuilder<ArticleModel>
39+
{
40+
public ArticleUpdateBuilder(string id,string userid)
41+
{
42+
base.Where(f => f.Id == id && f.Userid == userid);
43+
}
4444

45-
public ArticleUpdateBuilder(Action<ArticleModel> onChanged, string id, string userid) : base(onChanged)
46-
{
47-
base.Where(f => f.Id == id && f.Userid == userid);
48-
}
45+
public ArticleUpdateBuilder(Action<ArticleModel> onChanged, string id,string userid) : base(onChanged)
46+
{
47+
base.Where(f => f.Id == id && f.Userid == userid);
48+
}
4949

50-
public ArticleUpdateBuilder() { }
50+
public ArticleUpdateBuilder() { }
5151

52-
public new ArticleUpdateBuilder Where(Expression<Func<ArticleModel, bool>> predicate)
53-
{
54-
base.Where(predicate);
55-
return this;
56-
}
57-
public new ArticleUpdateBuilder Where(string formatCommad, params object[] pValue)
58-
{
59-
base.Where(formatCommad, pValue);
60-
return this;
61-
}
62-
public ArticleUpdateBuilder SetId(string id)
63-
{
64-
base.SetField("id", NpgsqlDbType.Varchar, id, -1, null);
65-
return this;
66-
}
67-
public ArticleUpdateBuilder SetUserid(string userid)
68-
{
69-
base.SetField("userid", NpgsqlDbType.Varchar, userid, -1, null);
70-
return this;
71-
}
72-
public ArticleUpdateBuilder SetTitle(string title)
73-
{
74-
base.SetField("title", NpgsqlDbType.Varchar, title, 255, null);
75-
return this;
76-
}
77-
public ArticleUpdateBuilder SetContent(JToken content)
78-
{
79-
base.SetField("content", NpgsqlDbType.Jsonb, content, -1, null);
80-
return this;
81-
}
82-
public ArticleUpdateBuilder SetCreatetime(DateTime createtime)
83-
{
84-
base.SetField("createtime", NpgsqlDbType.Timestamp, createtime, 8, null);
85-
return this;
86-
}
87-
}
52+
public new ArticleUpdateBuilder Where(Expression<Func<ArticleModel, bool>> predicate)
53+
{
54+
base.Where(predicate);
55+
return this;
56+
}
57+
public new ArticleUpdateBuilder Where(string expression)
58+
{
59+
base.Where(expression);
60+
return this;
61+
}
62+
public ArticleUpdateBuilder SetId(string id)
63+
{
64+
base.SetField("id", NpgsqlDbType.Varchar, id, -1, null);
65+
return this;
66+
}
67+
public ArticleUpdateBuilder SetUserid(string userid)
68+
{
69+
base.SetField("userid", NpgsqlDbType.Varchar, userid, -1, null);
70+
return this;
71+
}
72+
public ArticleUpdateBuilder SetTitle(string title)
73+
{
74+
base.SetField("title", NpgsqlDbType.Varchar, title, 255, null);
75+
return this;
76+
}
77+
public ArticleUpdateBuilder SetContent(JToken content)
78+
{
79+
base.SetField("content", NpgsqlDbType.Jsonb, content, -1, null);
80+
return this;
81+
}
82+
public ArticleUpdateBuilder SetCreatetime(DateTime createtime)
83+
{
84+
base.SetField("createtime", NpgsqlDbType.Timestamp, createtime, 8, null);
85+
return this;
86+
}
87+
}
8888

89-
}
89+
}
9090
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
using System;
2+
using System.Linq;
3+
using Newtonsoft.Json;
4+
using Newtonsoft.Json.Linq;
5+
using MyStaging;
6+
using MyStaging.Helpers;
7+
using MyStaging.Common;
8+
using NpgsqlTypes;
9+
using System.Linq.Expressions;
10+
using System.Collections.Generic;
11+
using MyStaging.xUnitTest.Model;
12+
using MyStaging.xUnitTest.Model.Schemas;
13+
14+
namespace MyStaging.xUnitTest.DAL
15+
{
16+
public partial class Topic : QueryContext<TopicModel>
17+
{
18+
public static Topic Context { get { return new Topic(); } }
19+
20+
public static InsertBuilder<TopicModel> InsertBuilder => new InsertBuilder<TopicModel>(TopicSchema.Instance);
21+
public static TopicModel Insert(TopicModel model) => InsertBuilder.Insert(model);
22+
public static int InsertRange(List<TopicModel> models) => InsertBuilder.InsertRange(models).SaveChange();
23+
24+
public static DeleteBuilder<TopicModel> DeleteBuilder => new DeleteBuilder<TopicModel>();
25+
public static int Delete(Guid id)
26+
{
27+
var affrows = DeleteBuilder.Where(f => f.Id == id).SaveChange();
28+
if (affrows > 0) PgSqlHelper.CacheManager?.RemoveItemCache<TopicModel>(id.ToString());
29+
return affrows;
30+
}
31+
32+
public static TopicUpdateBuilder UpdateBuilder => new TopicUpdateBuilder();
33+
public static TopicUpdateBuilder Update(Guid id)
34+
{
35+
return new TopicUpdateBuilder(null, id);
36+
}
37+
38+
public class TopicUpdateBuilder : UpdateBuilder<TopicModel>
39+
{
40+
public TopicUpdateBuilder(Guid id)
41+
{
42+
base.Where(f => f.Id == id);
43+
}
44+
45+
public TopicUpdateBuilder(Action<TopicModel> onChanged, Guid id) : base(onChanged)
46+
{
47+
base.Where(f => f.Id == id);
48+
}
49+
50+
public TopicUpdateBuilder() { }
51+
52+
public new TopicUpdateBuilder Where(Expression<Func<TopicModel, bool>> predicate)
53+
{
54+
base.Where(predicate);
55+
return this;
56+
}
57+
public new TopicUpdateBuilder Where(string expression)
58+
{
59+
base.Where(expression);
60+
return this;
61+
}
62+
public TopicUpdateBuilder SetId(Guid id)
63+
{
64+
base.SetField("id", NpgsqlDbType.Uuid, id, 16, null);
65+
return this;
66+
}
67+
public TopicUpdateBuilder SetTitle(string title)
68+
{
69+
base.SetField("title", NpgsqlDbType.Varchar, title, 255, null);
70+
return this;
71+
}
72+
public TopicUpdateBuilder SetCreate_time(DateTime? create_time)
73+
{
74+
base.SetField("create_time", NpgsqlDbType.Timestamp, create_time, 8, null);
75+
return this;
76+
}
77+
public TopicUpdateBuilder SetUpdate_time(DateTime? update_time)
78+
{
79+
base.SetField("update_time", NpgsqlDbType.Timestamp, update_time, 8, null);
80+
return this;
81+
}
82+
public TopicUpdateBuilder SetLast_time(DateTime? last_time)
83+
{
84+
base.SetField("last_time", NpgsqlDbType.Timestamp, last_time, 8, null);
85+
return this;
86+
}
87+
public TopicUpdateBuilder SetUser_id(Guid? user_id)
88+
{
89+
base.SetField("user_id", NpgsqlDbType.Uuid, user_id, 16, null);
90+
return this;
91+
}
92+
public TopicUpdateBuilder SetName(string name)
93+
{
94+
base.SetField("name", NpgsqlDbType.Varchar, name, 255, null);
95+
return this;
96+
}
97+
public TopicUpdateBuilder SetAge(int? age)
98+
{
99+
base.SetField("age", NpgsqlDbType.Integer, age, 4, null);
100+
return this;
101+
}
102+
public TopicUpdateBuilder SetSex(bool? sex)
103+
{
104+
base.SetField("sex", NpgsqlDbType.Boolean, sex, 1, null);
105+
return this;
106+
}
107+
public TopicUpdateBuilder SetCreatetime(DateTime? createtime)
108+
{
109+
base.SetField("createtime", NpgsqlDbType.Date, createtime, 4, null);
110+
return this;
111+
}
112+
public TopicUpdateBuilder SetUpdatetime(TimeSpan? updatetime)
113+
{
114+
base.SetField("updatetime", NpgsqlDbType.Time, updatetime, 8, null);
115+
return this;
116+
}
117+
}
118+
119+
}
120+
}

0 commit comments

Comments
 (0)