private static object InsertEntity(object entity, DataStrategy dataStrategy, string tableName) { var dictionary = entity as IDictionary<string, object>; if (dictionary != null) return dataStrategy.Insert(tableName, dictionary); var list = entity as IEnumerable<IDictionary<string, object>>; if (list != null) return dataStrategy.Insert(tableName, list); var entityList = entity as IEnumerable; if (entityList != null) { var array = entityList.Cast<object>().ToArray(); var rows = new List<IDictionary<string, object>>(); foreach (var o in array) { dictionary = (o as IDictionary<string, object>) ?? o.ObjectToDictionary(); if (dictionary.Count == 0) { throw new SimpleDataException("Could not discover data in object."); } rows.Add(dictionary); } return dataStrategy.Insert(tableName, rows); } dictionary = entity.ObjectToDictionary(); if (dictionary.Count == 0) throw new SimpleDataException("Could not discover data in object."); return dataStrategy.Insert(tableName, dictionary); }
private static object InsertEntity(object entity, DataStrategy dataStrategy, string tableName) { var dictionary = entity as IDictionary <string, object>; if (dictionary != null) { return(dataStrategy.Insert(tableName, dictionary)); } var list = entity as IEnumerable <IDictionary <string, object> >; if (list != null) { return(dataStrategy.Insert(tableName, list)); } var entityList = entity as IEnumerable; if (entityList != null) { var array = entityList.Cast <object>().ToArray(); var rows = new List <IDictionary <string, object> >(); foreach (var o in array) { dictionary = (o as IDictionary <string, object>) ?? o.ObjectToDictionary(); if (dictionary.Count == 0) { throw new SimpleDataException("Could not discover data in object."); } rows.Add(dictionary); } return(dataStrategy.Insert(tableName, rows)); } dictionary = entity.ObjectToDictionary(); if (dictionary.Count == 0) { throw new SimpleDataException("Could not discover data in object."); } return(dataStrategy.Insert(tableName, dictionary)); }
private static IDictionary<string,object> InsertEntity(object entity, DataStrategy dataStrategy, string tableName) { var dictionary = entity as IDictionary<string, object>; if (dictionary == null) { dictionary = ObjectEx.ObjectToDictionary(entity); if (dictionary.Count == 0) throw new SimpleDataException("Could not discover data in object."); } return dataStrategy.Insert(tableName, dictionary); }
private static IDictionary <string, object> InsertEntity(object entity, DataStrategy dataStrategy, string tableName) { var dictionary = entity as IDictionary <string, object>; if (dictionary == null) { dictionary = ObjectEx.ObjectToDictionary(entity); if (dictionary.Count == 0) { throw new SimpleDataException("Could not discover data in object."); } } return(dataStrategy.Insert(tableName, dictionary)); }
private static object InsertDictionary(InvokeMemberBinder binder, object[] args, DataStrategy dataStrategy, string tableName) { return dataStrategy.Insert(tableName, binder.NamedArgumentsToDictionary(args), !binder.IsResultDiscarded()); }
private static IDictionary <string, object> InsertDictionary(InvokeMemberBinder binder, object[] args, DataStrategy dataStrategy, string tableName) { return(dataStrategy.Insert(tableName, binder.NamedArgumentsToDictionary(args))); }
private static IDictionary<string, object> InsertDictionary(InvokeMemberBinder binder, object[] args, DataStrategy dataStrategy, string tableName) { return dataStrategy.Insert(tableName, binder.NamedArgumentsToDictionary(args)); }
private static object InsertDictionary(InvokeMemberBinder binder, object[] args, DataStrategy dataStrategy, string tableName) { return(dataStrategy.Insert(tableName, binder.NamedArgumentsToDictionary(args), !binder.IsResultDiscarded())); }