forked from ThatRendle/Simple.Data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectEx.cs
More file actions
20 lines (19 loc) · 764 Bytes
/
ObjectEx.cs
File metadata and controls
20 lines (19 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Simple.Data.Extensions
{
public static class ObjectEx
{
public static IDictionary<string, object> ObjectToDictionary(this object obj)
{
if (obj == null) return new Dictionary<string, object>();
return (from property in obj.GetType().GetProperties()
select
new KeyValuePair<string, object>(property.Name,
property.GetValue(obj, null)))
.ToDictionary();
}
}
}