예제 #1
0
        internal virtual string GetSqlFromTableInfo(SqlTableInfo sql)
        {
            SqlFieldList fieldList = new SqlFieldList(sql.TableName);

            fieldList.PrividerType = CurrPrividerType;
            foreach (var item in sql.Fields)
            {
                if (item.Key == "OBJECTID")
                {
                    continue;// “OBJECTID”是自增树列,会出现 SQL 语句无法更新标识列 2019/07/29
                }
                bool IsPkField = false;
                if (!string.IsNullOrEmpty(sql.KeyFieldName))
                {
                    IsPkField = item.Key.ToLower() == sql.KeyFieldName.ToLower();
                }
                if (IsPkField)
                {
                    fieldList.PrimaryField = new SqlField(item.Key, item.Value, CurrPrividerType);
                }
                if (CurrPrividerType == SqlPrividerType.Sqlite)
                {
                    if (item.Value is DateTime)
                    {
                        string str = ((DateTime)item.Value).ToString("s");
                        fieldList.AddNonPrimaryField(item.Key, str);
                    }
                    else
                    {
                        fieldList.AddNonPrimaryField(item.Key, item.Value);
                    }
                }
                else
                {
                    if (!DicTableToTableNameFields[sql.TableName].ContainsKey(item.Key))
                    {
                        continue;
                    }
                    var typeName = DicTableToTableNameFields[sql.TableName][item.Key];
                    if (typeName == "datetime" && item.Value != null && !string.IsNullOrEmpty(item.Value.ToString()))
                    {
                        var date = DateTime.Parse(item.Value.ToString());
                        fieldList.AddNonPrimaryField(item.Key, date);
                    }
                    else
                    {
                        fieldList.AddNonPrimaryField(item.Key, item.Value);
                    }
                }
                continue;
            }
            return(SqlFieldList.GetSqlString(fieldList));
        }
예제 #2
0
        internal virtual string GetSqlFromDelTableInfo(SqlTableInfo sql)
        {
            SqlFieldList fieldList = new SqlFieldList(sql.TableName);

            foreach (var item in sql.Fields)
            {
                bool IsPkField = false;
                if (!string.IsNullOrEmpty(sql.KeyFieldName))
                {
                    IsPkField = item.Key == sql.KeyFieldName;
                }

                if (IsPkField)
                {
                    fieldList.PrimaryField = new SqlField(item.Key, item.Value, CurrPrividerType);
                }
                fieldList.AddNonPrimaryField(item.Key, item.Value);
                continue;
            }
            return(fieldList.GetDeleteString());
        }