public override object TransformData(IFreeDocument datas) { object item = datas[Column]; IDataBaseConnector con = ConnectorSelector.SelectItem; if (con == null) { return(null); } TableInfo table = TableSelector.SelectItem; if (table == null) { return(null); } if (IsMutliDatas) { var r = con.TryFindEntities(table.Name, new Dictionary <string, object> { { KeyName, item } }, null, -1, SearchStrategy); if (r.Any() == false) { return(null); } var dicts = r.Select(d => d.DictSerialize()).ToList(); foreach (string importColumn in ImportColumns) { List <object> res = new List <object>(); for (int i = 0; i < dicts.Count; i++) { res.Add(dicts[i][importColumn]); } if (res.Count != 0) { datas.SetValue(importColumn, res); } } } else { var r = con.TryFindEntities(table.Name, new Dictionary <string, object> { { KeyName, item } }, null, 1, SearchStrategy).FirstOrDefault(); if (r == null) { return(null); } FreeDocument dict = r.DictSerialize(); foreach (string importColumn in ImportColumns) { datas.SetValue(importColumn, dict[importColumn]); } } return(null); }
public static List <T> TryFindEntities <T>(this IDataBaseConnector connector, string tableName, IDictionary <string, object> search) where T : class, IDictionarySerializable { var rs = connector.TryFindEntities(tableName, search, typeof(T)); return(rs.Select(d => d as T).ToList()); }