Exemple #1
0
        public static string GetSqlStatementByType(Type type, String crudType, string extTableName = null)
        {
            String key = type.Name + "." + crudType;

            if (!StatementParser.StatementCache.ContainsKey(key))
            {
                string sql = StatementParser.GetMappedStaticSql(key);
                if (sql.Equals(key))
                {
                    switch (crudType)
                    {
                    case "Update":
                        sql = MappingInfo.GetMappingInfo(type, extTableName).Update;
                        break;

                    case "Insert":
                        sql = MappingInfo.GetMappingInfo(type, extTableName).Insert;
                        break;

                    case "Delete":
                        sql = MappingInfo.GetMappingInfo(type).Delete;
                        break;

                    default:
                        throw new Exception("GetSqlStatementByType found Unknow CRUD key: " + key);
                    }
                }
                StatementParser.StatementCache.Insert(key, sql);
            }
            return((string)StatementParser.StatementCache.Get(key));
        }