Exemple #1
0
        public void Test_Build_Parameters_Uses_Runtime_Type()
        {
            var obj2Sql = new ObjectToSql(DataBaseType.SqlServer, true);
            var hashSet = new HashSet <Employee>(new List <Employee>()
            {
                new Employee()
                {
                    FirstName = "joif", LastName = "dsfi"
                }
            });
            var data = hashSet.ToList();

            if (data.GetType().IsTypeAnIEnumerable())
            {
                if (data is IEnumerable <object> list)
                {
                    foreach (var item in list)
                    {
                        var parameters = obj2Sql.BuildDbParameterList(item, delegate(string s, object o)
                                                                      { return(new SqlParameter(s, o)); });
                        Assert.That(parameters != null && parameters.Count == 2);
                    }
                }
            }
        }
 // HOW Tstatic O GENERATE DBParameters
 private static void HowToGenerateDBParameters()
 {
     var obj2Sql = new ObjectToSql(DataBaseType.SqlServer);
     List <DbParameter> dbParameters = obj2Sql.BuildDbParameterList(new Employee(), (s, o) => new SqlParameter(s, o));
 }