mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 12:28:15 +08:00
- 增加 ISelect`1 ToDictionary 方法查询返回字典;
This commit is contained in:
@ -251,6 +251,18 @@ namespace FreeSql.Tests.MySqlConnector
|
||||
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.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; }
|
||||
|
@ -183,6 +183,20 @@ namespace FreeSql.Tests.MsAccess
|
||||
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 testDto11 = select.Limit(10).ToDictionaryAsync(a => a.Id).Result;
|
||||
var testDto22 = select.Limit(10).ToDictionaryAsync(a => a.Id, a => new { a.Id, a.Title }).Result;
|
||||
|
||||
var repo = g.msaccess.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.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.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.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; }
|
||||
|
@ -192,6 +192,18 @@ namespace FreeSql.Tests.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; }
|
||||
|
@ -209,6 +209,18 @@ namespace FreeSql.Tests.Sqlite
|
||||
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.sqlite.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