pull/1/head
a.bozhenov 5 years ago
parent f9f1b6f34f
commit 5e62f6f3ff

@ -21,8 +21,5 @@ namespace ZeroLevel.SqlServer
void LazySelect(string query, DbParameter[] par, Func<DbDataReader, bool> readHandler);
void LazySelect(string query, DbParameter[] par, Func<DbDataReader, bool> readHandler, int timeout);
void LazySelectWithParameters(string query, IEnumerable<KeyValuePair<string, object>> par, Func<DbDataReader, bool> readHandler, int timeout);
T Read<T>(DbDataReader reader, int index);
T Read<T>(DbDataReader reader, string name);
}
}

@ -0,0 +1,29 @@
using System;
using System.Data.Common;
namespace ZeroLevel.SqlServer
{
public static class DBReader
{
public static T Read<T>(this DbDataReader reader, int index)
{
if (reader[index] == DBNull.Value) return default(T);
Type t;
if ((t = Nullable.GetUnderlyingType(typeof(T))) != null)
{
return (T)Convert.ChangeType(reader[index], t);
}
return (T)Convert.ChangeType(reader[index], typeof(T));
}
public static T Read<T>(this DbDataReader reader, string name)
{
if (reader[name] == DBNull.Value) return default(T);
Type t;
if ((t = Nullable.GetUnderlyingType(typeof(T))) != null)
{
return (T)Convert.ChangeType(reader[name], t);
}
return (T)Convert.ChangeType(reader[name], typeof(T));
}
}
}

@ -471,16 +471,5 @@ namespace ZeroLevel.SqlServer
}
}
#endregion
public T Read<T>(DbDataReader reader, int index)
{
if (reader[index] == DBNull.Value) return default(T);
return (T)Convert.ChangeType(reader[index], typeof(T));
}
public T Read<T>(DbDataReader reader, string name)
{
if (reader[name] == DBNull.Value) return default(T);
return (T)Convert.ChangeType(reader[name], typeof(T));
}
}
}

@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>

@ -52,5 +52,25 @@ namespace ZeroLevel.Services.Trees
}
}
}
/// <summary>
/// traversing a tree in width from left to right
/// </summary>
public IEnumerable<GNode<T>> Plain()
{
var queue = new Queue<GNode<T>>();
foreach (var r in _rootNodes) {
queue.Enqueue(r.Value);
}
while (queue.Count > 0)
{
var current = queue.Dequeue();
yield return current;
foreach (var r in current.Nodes)
{
queue.Enqueue(r.Value);
}
}
}
}
}
Loading…
Cancel
Save

Powered by TurnKey Linux.