Memory leaks fixed across the code related to cached reader.

Copyright date bump
This commit is contained in:
2026-02-21 10:03:59 +01:00
parent 1d60b48111
commit 918aa702d3
65 changed files with 2942 additions and 2336 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Description>Dynamic Object-Relational Mapping tests library.</Description> <Description>Dynamic Object-Relational Mapping tests library.</Description>
<Copyright>Copyright © RUSSEK Software 2012-2024</Copyright> <Copyright>Copyright © RUSSEK Software 2012-2026</Copyright>
<Company>RUSSEK Software</Company> <Company>RUSSEK Software</Company>
<Authors>Grzegorz Russek</Authors> <Authors>Grzegorz Russek</Authors>
<VersionPrefix>1.8</VersionPrefix> <VersionPrefix>1.8</VersionPrefix>

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Some of methods in this code file is based on Kerosene ORM solution * Some of methods in this code file is based on Kerosene ORM solution

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Some of methods in this code file is based on Kerosene ORM solution * Some of methods in this code file is based on Kerosene ORM solution

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Some of methods in this code file is based on Kerosene ORM solution * Some of methods in this code file is based on Kerosene ORM solution

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Some of methods in this code file is based on Kerosene ORM solution * Some of methods in this code file is based on Kerosene ORM solution

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Some of methods in this code file is based on Kerosene ORM solution * Some of methods in this code file is based on Kerosene ORM solution

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Some of methods in this code file is based on Kerosene ORM solution * Some of methods in this code file is based on Kerosene ORM solution

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Some of methods in this code file is based on Kerosene ORM solution * Some of methods in this code file is based on Kerosene ORM solution
@@ -139,15 +139,13 @@ namespace DynamORM.Builders.Implementation
/// <returns>Enumerator of objects expanded from query.</returns> /// <returns>Enumerator of objects expanded from query.</returns>
public virtual IEnumerable<dynamic> Execute() public virtual IEnumerable<dynamic> Execute()
{ {
DynamicCachedReader cache = null;
using (IDbConnection con = Database.Open()) using (IDbConnection con = Database.Open())
using (IDbCommand cmd = con.CreateCommand()) using (IDbCommand cmd = con.CreateCommand())
{ {
using (IDataReader rdr = cmd using (IDataReader rdr = cmd
.SetCommand(this) .SetCommand(this)
.ExecuteReader()) .ExecuteReader())
cache = new DynamicCachedReader(rdr); using (IDataReader cache = new DynamicCachedReader(rdr))
while (cache.Read()) while (cache.Read())
{ {
dynamic val = null; dynamic val = null;
@@ -163,7 +161,8 @@ namespace DynamORM.Builders.Implementation
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
cmd.Dump(sb); cmd.Dump(sb);
throw new ArgumentException(string.Format("{0}{1}{2}", argex.Message, Environment.NewLine, sb), throw new ArgumentException(
string.Format("{0}{1}{2}", argex.Message, Environment.NewLine, sb),
argex.InnerException.NullOr(a => a, argex)); argex.InnerException.NullOr(a => a, argex));
} }
@@ -177,7 +176,6 @@ namespace DynamORM.Builders.Implementation
/// <returns>Enumerator of objects expanded from query.</returns> /// <returns>Enumerator of objects expanded from query.</returns>
public virtual IEnumerable<T> Execute<T>() where T : class public virtual IEnumerable<T> Execute<T>() where T : class
{ {
DynamicCachedReader cache = null;
DynamicTypeMap mapper = DynamicMapperCache.GetMapper<T>(); DynamicTypeMap mapper = DynamicMapperCache.GetMapper<T>();
if (mapper == null) if (mapper == null)
@@ -189,8 +187,7 @@ namespace DynamORM.Builders.Implementation
using (IDataReader rdr = cmd using (IDataReader rdr = cmd
.SetCommand(this) .SetCommand(this)
.ExecuteReader()) .ExecuteReader())
cache = new DynamicCachedReader(rdr); using (IDataReader cache = new DynamicCachedReader(rdr))
while (cache.Read()) while (cache.Read())
{ {
dynamic val = null; dynamic val = null;
@@ -206,7 +203,8 @@ namespace DynamORM.Builders.Implementation
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
cmd.Dump(sb); cmd.Dump(sb);
throw new ArgumentException(string.Format("{0}{1}{2}", argex.Message, Environment.NewLine, sb), throw new ArgumentException(
string.Format("{0}{1}{2}", argex.Message, Environment.NewLine, sb),
argex.InnerException.NullOr(a => a, argex)); argex.InnerException.NullOr(a => a, argex));
} }
@@ -232,15 +230,12 @@ namespace DynamORM.Builders.Implementation
/// <param name="reader">Action containing reader.</param> /// <param name="reader">Action containing reader.</param>
public virtual void ExecuteCachedDataReader(Action<IDataReader> reader) public virtual void ExecuteCachedDataReader(Action<IDataReader> reader)
{ {
DynamicCachedReader cache = null;
using (IDbConnection con = Database.Open()) using (IDbConnection con = Database.Open())
using (IDbCommand cmd = con.CreateCommand()) using (IDbCommand cmd = con.CreateCommand())
using (IDataReader rdr = cmd using (IDataReader rdr = cmd
.SetCommand(this) .SetCommand(this)
.ExecuteReader()) .ExecuteReader())
cache = new DynamicCachedReader(rdr); using (IDataReader cache = new DynamicCachedReader(rdr))
reader(cache); reader(cache);
} }

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Some of methods in this code file is based on Kerosene ORM solution * Some of methods in this code file is based on Kerosene ORM solution

View File

@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0;net472;net6.0;net8.0;net10.0</TargetFrameworks> <TargetFrameworks>netstandard2.0;net472;net6.0;net8.0;net10.0</TargetFrameworks>
<Description>Dynamic Object-Relational Mapping library.</Description> <Description>Dynamic Object-Relational Mapping library.</Description>
<Copyright>Copyright © RUSSEK Software 2012-2024</Copyright> <Copyright>Copyright © RUSSEK Software 2012-2026</Copyright>
<Company>RUSSEK Software</Company> <Company>RUSSEK Software</Company>
<Authors>Grzegorz Russek</Authors> <Authors>Grzegorz Russek</Authors>
<VersionPrefix>1.9</VersionPrefix> <VersionPrefix>1.9</VersionPrefix>

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -1327,7 +1327,6 @@ namespace DynamORM
/// <returns>Enumerator of objects expanded from query.</returns> /// <returns>Enumerator of objects expanded from query.</returns>
public virtual IEnumerable<dynamic> Query(string sql, params object[] args) public virtual IEnumerable<dynamic> Query(string sql, params object[] args)
{ {
DynamicCachedReader cache = null;
using (IDbConnection con = Open()) using (IDbConnection con = Open())
using (IDbCommand cmd = con.CreateCommand()) using (IDbCommand cmd = con.CreateCommand())
{ {
@@ -1335,8 +1334,8 @@ namespace DynamORM
.SetCommand(sql) .SetCommand(sql)
.AddParameters(this, args) .AddParameters(this, args)
.ExecuteReader()) .ExecuteReader())
cache = new DynamicCachedReader(rdr); using (IDataReader cache = new DynamicCachedReader(rdr))
{
while (cache.Read()) while (cache.Read())
{ {
dynamic val = null; dynamic val = null;
@@ -1352,7 +1351,8 @@ namespace DynamORM
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
cmd.Dump(sb); cmd.Dump(sb);
throw new ArgumentException(string.Format("{0}{1}{2}", argex.Message, Environment.NewLine, sb), throw new ArgumentException(
string.Format("{0}{1}{2}", argex.Message, Environment.NewLine, sb),
argex.InnerException.NullOr(a => a, argex)); argex.InnerException.NullOr(a => a, argex));
} }
@@ -1360,21 +1360,20 @@ namespace DynamORM
} }
} }
} }
}
/// <summary>Enumerate the reader and yield the result.</summary> /// <summary>Enumerate the reader and yield the result.</summary>
/// <param name="builder">Command builder.</param> /// <param name="builder">Command builder.</param>
/// <returns>Enumerator of objects expanded from query.</returns> /// <returns>Enumerator of objects expanded from query.</returns>
public virtual IEnumerable<dynamic> Query(IDynamicQueryBuilder builder) public virtual IEnumerable<dynamic> Query(IDynamicQueryBuilder builder)
{ {
DynamicCachedReader cache = null;
using (IDbConnection con = Open()) using (IDbConnection con = Open())
using (IDbCommand cmd = con.CreateCommand()) using (IDbCommand cmd = con.CreateCommand())
{ {
using (IDataReader rdr = cmd using (IDataReader rdr = cmd
.SetCommand(builder) .SetCommand(builder)
.ExecuteReader()) .ExecuteReader())
cache = new DynamicCachedReader(rdr); using (var cache = new DynamicCachedReader(rdr))
while (cache.Read()) while (cache.Read())
{ {
dynamic val = null; dynamic val = null;
@@ -1390,7 +1389,8 @@ namespace DynamORM
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
cmd.Dump(sb); cmd.Dump(sb);
throw new ArgumentException(string.Format("{0}{1}{2}", argex.Message, Environment.NewLine, sb), throw new ArgumentException(
string.Format("{0}{1}{2}", argex.Message, Environment.NewLine, sb),
argex.InnerException.NullOr(a => a, argex)); argex.InnerException.NullOr(a => a, argex));
} }

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -282,17 +282,16 @@ namespace DynamORM
else if (types[0] == typeof(DataTable)) else if (types[0] == typeof(DataTable))
{ {
using (IDataReader rdr = cmd.ExecuteReader()) using (IDataReader rdr = cmd.ExecuteReader())
mainResult = rdr.CachedReader().ToDataTable(binder.Name); using (IDataReader cache = rdr.CachedReader())
mainResult = cache.ToDataTable(binder.Name);
} }
else if (types[0].IsGenericEnumerable()) else if (types[0].IsGenericEnumerable())
{ {
Type argType = types[0].GetGenericArguments().First(); Type argType = types[0].GetGenericArguments().First();
if (argType == typeof(object)) if (argType == typeof(object))
{ {
IDataReader cache = null;
using (IDataReader rdr = cmd.ExecuteReader()) using (IDataReader rdr = cmd.ExecuteReader())
cache = rdr.CachedReader(); using (IDataReader cache = rdr.CachedReader())
mainResult = cache.EnumerateReader().ToList(); mainResult = cache.EnumerateReader().ToList();
} }
else if (argType.IsValueType || argType == typeof(string)) else if (argType.IsValueType || argType == typeof(string))
@@ -302,10 +301,8 @@ namespace DynamORM
object defVal = listType.GetDefaultValue(); object defVal = listType.GetDefaultValue();
IDataReader cache = null;
using (IDataReader rdr = cmd.ExecuteReader()) using (IDataReader rdr = cmd.ExecuteReader())
cache = rdr.CachedReader(); using (IDataReader cache = rdr.CachedReader())
while (cache.Read()) while (cache.Read())
listInstance.Add(cache[0] != null && cache[0] != DBNull.Value ? argType.CastObject(cache[0]) : defVal); listInstance.Add(cache[0] != null && cache[0] != DBNull.Value ? argType.CastObject(cache[0]) : defVal);
@@ -318,10 +315,8 @@ namespace DynamORM
object defVal = listType.GetDefaultValue(); object defVal = listType.GetDefaultValue();
IDataReader cache = null;
using (IDataReader rdr = cmd.ExecuteReader()) using (IDataReader rdr = cmd.ExecuteReader())
cache = rdr.CachedReader(); using (IDataReader cache = rdr.CachedReader())
while (cache.Read()) while (cache.Read())
{ {
if (cache[0] != null && cache[0] != DBNull.Value && Guid.TryParse(cache[0].ToString(), out Guid g)) if (cache[0] != null && cache[0] != DBNull.Value && Guid.TryParse(cache[0].ToString(), out Guid g))
@@ -336,10 +331,9 @@ namespace DynamORM
if (mapper == null) if (mapper == null)
throw new InvalidCastException(string.Format("Don't know what to do with this type: '{0}'.", argType.ToString())); throw new InvalidCastException(string.Format("Don't know what to do with this type: '{0}'.", argType.ToString()));
IDataReader cache = null;
using (IDataReader rdr = cmd.ExecuteReader()) using (IDataReader rdr = cmd.ExecuteReader())
cache = rdr.CachedReader(); using (IDataReader cache = rdr.CachedReader())
{
var lt = typeof(List<>); var lt = typeof(List<>);
var ltc = lt.MakeGenericType(argType); var ltc = lt.MakeGenericType(argType);
var instance = Activator.CreateInstance(ltc) as IList; var instance = Activator.CreateInstance(ltc) as IList;
@@ -348,6 +342,7 @@ namespace DynamORM
instance.Add(DynamicExtensions.Map(item, argType)); instance.Add(DynamicExtensions.Map(item, argType));
mainResult = instance; mainResult = instance;
}
//mainResult = cache.EnumerateReader().MapEnumerable(argType).ToList(); //mainResult = cache.EnumerateReader().MapEnumerable(argType).ToList();
} }

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* This code file is based on Kerosene ORM solution for parsing dynamic * This code file is based on Kerosene ORM solution for parsing dynamic

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,6 +1,6 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without