示例#1
0
        private void BuildInsertIntoTableScriptForVariable(MyQuery Query, String TableName, Object Value)
        {
            if (MyTypeHelper.IsPrimitive(Value))
            {
            }

            else if (Value is IDictionary <string, object> dict)
            {
                Query.Append("insert into @").Append(TableName).Append(" (");
                Int32 index = 0;
                foreach (var keyAndValue in dict)
                {
                    if (index > 0)
                    {
                        Query.Append(", ");
                    }
                    Query.Append(keyAndValue.Key);
                    index++;
                }
                Query.Append(") values (");
                index = 0;
                foreach (var keyAndValue in dict)
                {
                    if (index > 0)
                    {
                        Query.Append(", ");
                    }
                    Query.AppendVal(keyAndValue.Value);
                    index++;
                }
                Query.Append(");");
            }

            else if (Value is IList)
            {
            }

            else if (Value.GetType().IsClass)
            {
                BuildInsertIntoTableScriptForVariable(Query, TableName, ReflectionHelper.ToDictionary(Value));
            }
        }