Browse Source

Update accress

pull/14/head
sunkaixuan 3 years ago
parent
commit
f66d76c4b5
  1. 4
      Src/Asp.Net/AccessTest/Demo/Demo1_Queryable.cs
  2. BIN
      Src/Asp.Net/AccessTest/Test.accdb
  3. 50
      Src/Asp.Net/SqlSugar.Access/Access/SqlBuilder/AccessExpressionContext.cs

4
Src/Asp.Net/AccessTest/Demo/Demo1_Queryable.cs

@ -121,7 +121,7 @@ namespace OrmTest
//var test02 = db.Union(q1, q2).ToList();
var test03 = db.Queryable<Order>().Take(1).ToList();
var dp = DateTime.Now;
//var test05 = db.Queryable<Order>().Where(it => it.CreateTime.Month== dp.Month).ToList();
var test05 = db.Queryable<Order>().Where(it => it.CreateTime.Month== dp.Month).ToList();
var test06 = db.Queryable<Order>()
.ToPivotTable(it => it.Id, it => it.Name, it => it.Sum(x => x.Price));
@ -153,7 +153,7 @@ namespace OrmTest
JoinType.Left, o.Name == SqlFunc.ToString(SqlFunc.MergeString(",", i.Name, ","))
))
.Select<ViewOrder>().ToList();
var test16 = db.Queryable<Order>().Select(it => SqlFunc.SqlServer_DateDiff("day", DateTime.Now.AddDays(-1), DateTime.Now)).ToList();
// var test16 = db.Queryable<Order>().Select(it => SqlFunc.SqlServer_DateDiff("day", DateTime.Now.AddDays(-1), DateTime.Now)).ToList();
var test17 =
db.Queryable<Order>()
.Select<Order>()

BIN
Src/Asp.Net/AccessTest/Test.accdb

Binary file not shown.

50
Src/Asp.Net/SqlSugar.Access/Access/SqlBuilder/AccessExpressionContext.cs

@ -20,6 +20,56 @@ namespace SqlSugar.Access
}
public partial class AccessMethod : DefaultDbMethod, IDbMethods
{
public override string ToDate(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
return string.Format(" CDate({0}) ", parameter.MemberName);
}
public override string ToBool(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
return string.Format(" CDate({0}) ", parameter.MemberName);
}
public override string ToInt32(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
return string.Format(" CInt({0}) ", parameter.MemberName);
}
public override string ToString(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
return string.Format(" CVar({0}) ", parameter.MemberName);
}
public override string ToDateShort(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
return string.Format(" Format$({0},\"Long Date\") ", parameter.MemberName);
}
public override string DateValue(MethodCallExpressionModel model)
{
var type = "";
if (model.Args[1].MemberValue.ObjToString() == "Day")
{
type = "d";
}
if (model.Args[1].MemberValue.ObjToString() == "Month")
{
type = "m";
}
if (model.Args[1].MemberValue.ObjToString() == "Year")
{
type = "yyyy";
}
if (model.Args[1].MemberValue.ObjToString() == DateType.Minute.ToString())
{
type = "M";
}
if (model.Args[1].MemberValue.ObjToString() == DateType.Second.ToString())
{
type = "s";
}
return "DATEPART(\""+ type + "\", date())";
}
public override string GetRandom()
{
return " rnd() ";

Loading…
Cancel
Save