mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-12-15 15:15:47 +08:00
- 增加 ISelect`1 ToDictionary 方法查询返回字典;
This commit is contained in:
@@ -192,6 +192,18 @@ namespace FreeSql.Tests.Odbc.Dameng
|
||||
var t11 = select.Where(a => a.Type.Name.Length > 0).ToList(true);
|
||||
var t21 = select.Where(a => a.Type.Parent.Name.Length > 0).ToList(true);
|
||||
}
|
||||
[Fact]
|
||||
public void ToDictionary()
|
||||
{
|
||||
var testDto1 = select.Limit(10).ToDictionary(a => a.Id);
|
||||
var testDto2 = select.Limit(10).ToDictionary(a => a.Id, a => new { a.Id, a.Title });
|
||||
|
||||
var repo = g.dameng.GetRepository<Topic>();
|
||||
var dic = repo.Select.Limit(10).ToDictionary(a => a.Id);
|
||||
var first = dic.First().Value;
|
||||
first.Clicks++;
|
||||
repo.Update(first);
|
||||
}
|
||||
class TestGuidIdToList
|
||||
{
|
||||
public Guid id { get; set; }
|
||||
|
||||
@@ -183,6 +183,18 @@ namespace FreeSql.Tests.Odbc.Default
|
||||
var t11 = select.Where(a => a.Type.Name.Length > 0).ToList(true);
|
||||
var t21 = select.Where(a => a.Type.Parent.Name.Length > 0).ToList(true);
|
||||
}
|
||||
[Fact]
|
||||
public void ToDictionary()
|
||||
{
|
||||
var testDto1 = select.Limit(10).ToDictionary(a => a.Id);
|
||||
var testDto2 = select.Limit(10).ToDictionary(a => a.Id, a => new { a.Id, a.Title });
|
||||
|
||||
var repo = g.odbc.GetRepository<Topic>();
|
||||
var dic = repo.Select.Limit(10).ToDictionary(a => a.Id);
|
||||
var first = dic.First().Value;
|
||||
first.Clicks++;
|
||||
repo.Update(first);
|
||||
}
|
||||
class TestGuidIdToList
|
||||
{
|
||||
public Guid id { get; set; }
|
||||
|
||||
@@ -292,6 +292,18 @@ namespace FreeSql.Tests.Odbc.MySql
|
||||
var t11 = select.Where(a => a.Type.Name.Length > 0).ToList(true);
|
||||
var t21 = select.Where(a => a.Type.Parent.Name.Length > 0).ToList(true);
|
||||
}
|
||||
[Fact]
|
||||
public void ToDictionary()
|
||||
{
|
||||
var testDto1 = select.Limit(10).ToDictionary(a => a.Id);
|
||||
var testDto2 = select.Limit(10).ToDictionary(a => a.Id, a => new { a.Id, a.Title });
|
||||
|
||||
var repo = g.mysql.GetRepository<Topic>();
|
||||
var dic = repo.Select.Limit(10).ToDictionary(a => a.Id);
|
||||
var first = dic.First().Value;
|
||||
first.Clicks++;
|
||||
repo.Update(first);
|
||||
}
|
||||
class TestGuidIdToList
|
||||
{
|
||||
public Guid id { get; set; }
|
||||
|
||||
@@ -192,6 +192,18 @@ namespace FreeSql.Tests.Odbc.Oracle
|
||||
var t11 = select.Where(a => a.Type.Name.Length > 0).ToList(true);
|
||||
var t21 = select.Where(a => a.Type.Parent.Name.Length > 0).ToList(true);
|
||||
}
|
||||
[Fact]
|
||||
public void ToDictionary()
|
||||
{
|
||||
var testDto1 = select.Limit(10).ToDictionary(a => a.Id);
|
||||
var testDto2 = select.Limit(10).ToDictionary(a => a.Id, a => new { a.Id, a.Title });
|
||||
|
||||
var repo = g.oracle.GetRepository<Topic>();
|
||||
var dic = repo.Select.Limit(10).ToDictionary(a => a.Id);
|
||||
var first = dic.First().Value;
|
||||
first.Clicks++;
|
||||
repo.Update(first);
|
||||
}
|
||||
class TestGuidIdToList
|
||||
{
|
||||
public Guid id { get; set; }
|
||||
|
||||
@@ -268,6 +268,18 @@ namespace FreeSql.Tests.Odbc.PostgreSQL
|
||||
var t11 = select.Where(a => a.Type.Name.Length > 0).ToList(true);
|
||||
var t21 = select.Where(a => a.Type.Parent.Name.Length > 0).ToList(true);
|
||||
}
|
||||
[Fact]
|
||||
public void ToDictionary()
|
||||
{
|
||||
var testDto1 = select.Limit(10).ToDictionary(a => a.Id);
|
||||
var testDto2 = select.Limit(10).ToDictionary(a => a.Id, a => new { a.Id, a.Title });
|
||||
|
||||
var repo = g.pgsql.GetRepository<Topic>();
|
||||
var dic = repo.Select.Limit(10).ToDictionary(a => a.Id);
|
||||
var first = dic.First().Value;
|
||||
first.Clicks++;
|
||||
repo.Update(first);
|
||||
}
|
||||
class TestGuidIdToList
|
||||
{
|
||||
public Guid id { get; set; }
|
||||
|
||||
@@ -182,6 +182,18 @@ namespace FreeSql.Tests.Odbc.SqlServer
|
||||
var t11 = select.Where(a => a.Type.Name.Length > 0).ToList(true);
|
||||
var t21 = select.Where(a => a.Type.Parent.Name.Length > 0).ToList(true);
|
||||
}
|
||||
[Fact]
|
||||
public void ToDictionary()
|
||||
{
|
||||
var testDto1 = select.Limit(10).ToDictionary(a => a.Id);
|
||||
var testDto2 = select.Limit(10).ToDictionary(a => a.Id, a => new { a.Id, a.Title });
|
||||
|
||||
var repo = g.sqlserver.GetRepository<Topic>();
|
||||
var dic = repo.Select.Limit(10).ToDictionary(a => a.Id);
|
||||
var first = dic.First().Value;
|
||||
first.Clicks++;
|
||||
repo.Update(first);
|
||||
}
|
||||
class TestGuidIdToList
|
||||
{
|
||||
public Guid id { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user