forked from liningit/Dapper.LnskyDB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request liningit#4 from liningit/liningit
V2.0.0
- Loading branch information
Showing
31 changed files
with
1,542 additions
and
610 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
* 增删改查操作 | ||
* [不分库分表](/noshuffled) | ||
* [分库分表](/shuffled) | ||
* [连表查询](/join) | ||
* [高级操作](/advanced) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# 连表查询 | ||
|
||
v2.0版本支持多表查询了 | ||
步骤如下 | ||
1. 调用方法是通过`IQuery.OuterJoin`或者`IQuery.InnerJoin`进行连表查询,返回IJoinQuery对象. | ||
1. 可以调用`IJoinQuery.And,Or`进行条件过滤.调用`Select`返回`ISelectResult`. | ||
1. 通过仓储的`GetList`或`GetPaging`进行返回结果. | ||
```csharp | ||
var repository = GetRepository(); | ||
var query = QueryFactory.Create<ProductSaleByDayNSEntity>(m => DBFunction.Function<DateTime>("ISNULL", m.UpdateDate, DateTime.Now) > new DateTime(2019, 6, 26)); | ||
var jq = query.InnerJoin(QueryFactory.Create<ShopEntity>(), m => m.ShopID, m => m.SysNo, (x, y) => new { Sale = x, Shop = y }); | ||
jq.And(m => m.Shop.ShopName.Contains("店铺")); | ||
jq.OrderByDescing(m => m.Sale.Sales + 1); | ||
jq.OrderBy(m => m.Sale.ProductName + m.Sale.OutProductID); | ||
jq.StarSize = 10; | ||
jq.Rows = 5; | ||
var res = jq.Select(m => m.Sale); | ||
var paging = repository.GetPaging(res); | ||
//也可以下面这样返回dto.第二个参数表示第一个表是否要查询所有列. | ||
var res2 = jq.Select(m => new PSDto { ShopName = m.Shop.ShopName }, true); | ||
var paging2 = repository.GetPaging(res2); | ||
var count = paging.TotalCount; | ||
var lst = paging.ToList();//或者paging.Items | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using LnskyDB.Model; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Immutable; | ||
namespace LnskyDB.Demo.Entity.Data | ||
{ | ||
public class ShopEntity : BaseDBModel | ||
{ | ||
private static ImmutableList<string> _DBModel_PKCols = ImmutableList.Create("SysNo"); | ||
public override ImmutableList<string> GetDBModel_PKCols() => _DBModel_PKCols; | ||
|
||
|
||
public override string GetDBModel_TableName() => "Data_Shop{0}"; | ||
public override string GetDBModel_DBName() => "LnskyNS{0}"; | ||
|
||
#region Model | ||
|
||
Guid _SysNo; | ||
/// <summary> | ||
/// 系统编号 | ||
/// </summary> | ||
public Guid SysNo { get { return _SysNo; } set { Change("SysNo"); _SysNo = value; } } | ||
|
||
string _ShopCode; | ||
/// <summary> | ||
/// 店铺编码 | ||
/// </summary> | ||
public string ShopCode { get { return _ShopCode; } set { Change("ShopCode"); _ShopCode = value; } } | ||
|
||
string _ShopName; | ||
/// <summary> | ||
/// 店铺名称 | ||
/// </summary> | ||
public string ShopName { get { return _ShopName; } set { Change("ShopName"); _ShopName = value; } } | ||
|
||
int? _ShopType; | ||
/// <summary> | ||
/// 店铺类型 | ||
/// </summary> | ||
public int? ShopType { get { return _ShopType; } set { Change("ShopType"); _ShopType = value; } } | ||
|
||
#endregion Model | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace LnskyDB.Demo | ||
{ | ||
public class PSDto | ||
{ | ||
public Guid SysNo { get; set; } | ||
public string DataSource { get; set; } | ||
public string OutProductID { get; set; } | ||
public Guid ShopID { get; set; } | ||
public DateTime StatisticalDate { get; set; } | ||
public decimal Sales { get; set; } | ||
public string ShopName { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using LnskyDB; | ||
using LnskyDB.Demo.Entity.Data; | ||
using LnskyDB.Demo.RepositoryInterface.Data; | ||
|
||
namespace LnskyDB.Demo.Repository.Data | ||
{ | ||
public class ShopRepository : Repository<ShopEntity>, IShopRepository | ||
{ | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using LnskyDB; | ||
using LnskyDB.Demo.Entity.Data; | ||
|
||
namespace LnskyDB.Demo.RepositoryInterface.Data | ||
{ | ||
public interface IShopRepository : IRepository<ShopEntity> | ||
{ | ||
} | ||
} |
Oops, something went wrong.