@@ -58,20 +58,65 @@ public static bool Save<T>(string connString, List<T> entities, string[] keys =
5858 return entityDataHandler . SaveEntities ( entities , tableName ?? typeof ( T ) . Name , keys , SaveType . InsertOrUpdate , identity ) ;
5959 }
6060 }
61- #endregion Save Methods
62-
63- #region Load Methods
6461
65- #region Connection Depending
6662 /// <summary>
67- /// Load single entity from database
63+ /// Save a list of entities to the database
6864 /// </summary>
65+ /// <param name="connection">Current active SQL connection</param>
66+ /// <param name="entities">list of entities that needs to be committed to the database</param>
67+ /// <param name="keys"></param>
68+ /// <param name="identity">coloumn in database the represents the id</param>
69+ /// <param name="tableName">name of sqltable - if null, will use entitytype name as tablename</param>
6970 /// <typeparam name="T">entity type</typeparam>
70- /// <param name="connection">connection to database</param>
71- /// <param name="keyValue"></param>
71+ /// <returns>true or false for success status</returns>
72+ public static bool Save < T > ( SqlConnection connection , List < T > entities , string [ ] keys = null , string identity = "Id" ,
73+ string tableName = null ) where T : class
74+ {
75+ ValidateConnection ( connection ) ;
76+
77+ if ( keys == null || keys . Length == 0 )
78+ keys = new [ ] { identity } ;
79+
80+ GenericSQLEntityHandler entityDataHandler = new GenericSQLEntityHandler ( connection ) ;
81+ return entityDataHandler . SaveEntities ( entities , tableName ?? typeof ( T ) . Name , keys , SaveType . InsertOrUpdate , identity ) ;
82+ }
83+
84+ /// <summary>
85+ /// Save a single entity to the database
86+ /// </summary>
87+ /// <param name="connection">Current active SQL connection</param>
88+ /// <param name="entity">entity that needs to be committed to the database</param>
89+ /// <param name="keys"></param>
7290 /// <param name="identity">coloumn in database the represents the id</param>
7391 /// <param name="tableName">name of sqltable - if null, will use entitytype name as tablename</param>
74- /// <returns>found entity of the specified type or null if nothing is found or caused an exception</returns>
92+ /// <typeparam name="T">entity type</typeparam>
93+ /// <returns>true or false for success status</returns>
94+ public static bool Save < T > ( SqlConnection connection , T entity , string [ ] keys = null , string identity = "Id" ,
95+ string tableName = null ) where T : class
96+ {
97+ ValidateConnection ( connection ) ;
98+
99+ if ( keys == null || keys . Length == 0 )
100+ keys = new [ ] { identity } ;
101+
102+ GenericSQLEntityHandler entityDataHandler = new GenericSQLEntityHandler ( connection ) ;
103+ return entityDataHandler . SaveEntity ( entity , tableName ?? typeof ( T ) . Name , keys , SaveType . InsertOrUpdate , identity ) ;
104+ }
105+
106+ #endregion Save Methods
107+
108+ #region Load Methods
109+
110+ #region Connection Depending
111+ /// <summary>
112+ /// Load single entity from database
113+ /// </summary>
114+ /// <typeparam name="T">entity type</typeparam>
115+ /// <param name="connection">connection to database</param>
116+ /// <param name="keyValue"></param>
117+ /// <param name="identity">coloumn in database the represents the id</param>
118+ /// <param name="tableName">name of sqltable - if null, will use entitytype name as tablename</param>
119+ /// <returns>found entity of the specified type or null if nothing is found or caused an exception</returns>
75120 public static T Load < T > ( SqlConnection connection , object keyValue , string identity = "Id" ,
76121 string tableName = null ) where T : class
77122 {
0 commit comments